From 29951a830e186390fea914b3d94920481ff20109 Mon Sep 17 00:00:00 2001 From: Steven McGrath Date: Wed, 13 Mar 2019 16:00:53 -0500 Subject: [PATCH 1/2] Moved app and config within the sclack package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moved the app.py and config.json files within the sclack package and updated the setup.py to use the refactored entrypoint to start the script. This should make the sclack application installable from pip. and usable via the commandline as “sclack” --- app.py => sclack/app.py | 9 +++++++-- config.json => sclack/config.json | 0 setup.py | 9 ++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) rename app.py => sclack/app.py (99%) rename config.json => sclack/config.json (100%) diff --git a/app.py b/sclack/app.py similarity index 99% rename from app.py rename to sclack/app.py index 70afea8..b1f6dc0 100755 --- a/app.py +++ b/sclack/app.py @@ -958,10 +958,15 @@ def ask_for_token(json_config): config_file.write(json.dumps(token_config, indent=False)) json_config.update(token_config) -if __name__ == '__main__': +def run(): json_config = {} - with open('./config.json', 'r') as config_file: + config_file = os.path.join( + os.path.dirname(os.path.realpath(__file__)), 'config.json') + with open(config_file, 'r') as config_file: json_config.update(json.load(config_file)) ask_for_token(json_config) app = App(json_config) app.start() + +if __name__ == '__main__': + run() diff --git a/config.json b/sclack/config.json similarity index 100% rename from config.json rename to sclack/config.json diff --git a/setup.py b/setup.py index 9e73b2b..c0418a1 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,14 @@ author='Marcelo Camargo', author_email='marcelocamargo@linuxmail.org', url='https://github.com/haskellcamargo/sclack', - scripts=["app.py"], + entry_points={ + 'console_scripts': [ + 'sclack=sclack.app:run', + ], + }, + package_data={ + 'sclack': ['config.json'] + }, packages=find_packages(), install_requires=[ 'asyncio', From 5debbe13594ac8914b8ed269b4e4448c461f1e40 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Sun, 7 Feb 2021 13:17:15 +0100 Subject: [PATCH 2/2] Update tests for the new location of app.py --- tests/test_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index 952088a..72faab0 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1,5 +1,5 @@ from sclack.quick_switcher import remove_diacritic -from app import ask_for_token +from sclack.app import ask_for_token from slackclient import SlackClient @@ -58,4 +58,4 @@ def test_get_members_pagination2(): limit=10, # 1k is max limit types='public_channel,private_channel,im') members = client.api_call('conversations.members', channel=channels['channels'][0]['id'], limit=1) - assert members != None and members.get('response_metadata', None) != None \ No newline at end of file + assert members != None and members.get('response_metadata', None) != None