forked from CruiseDevice/twweet-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
105 lines (84 loc) · 2.92 KB
/
Copy pathsetup.py
File metadata and controls
105 lines (84 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
"""A setuptools based setup module.
See:
https://packaging.python.org/en/latest/distributing.html
https://github.com/pypa/sampleproject
"""
from setuptools.command.install import install
from setuptools import setup, find_packages
from codecs import open
from os import path
from os.path import expanduser
import os,json
import shutil
here = path.abspath(path.dirname(__file__))
home = expanduser("~")
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
class TwtApiDetails(install):
def run(self):
print("Creating Data Directories...")
check_data_dir_exists()
createCreds()
print("Creating default config files. Please note that this overwrites the files if exist....")
with open(home+'/.twweet-cli/data/config.yml','w') as ymlfile:
ymlFilecontent = """#Dependig on the system(Windows or Linux) change the backward or forward slash appropriately.
Tweets: /TweetsStore/
HashTag : /HashTagStore/
"""
ymlfile.write(ymlFilecontent)
install.run(self)
def check_data_dir_exists():
try:
original_umask = os.umask(0)
if os.path.exists(home+'/.twweet-cli/data'):
response = input("The data directory already exists. Would you like to overwrite?yes/no:")
if response.lower() == 'yes':
shutil.rmtree(home+'/.twweet-cli/data')
os.makedirs(home+'/.twweet-cli/data')
except OSError:
print("Cannot create data dir the installation cannot continue..")
exit()
finally:
os.umask(original_umask)
def createCreds():
ck = input('Enter your Consumer Key: ').strip()
cs = input('Enter your Consumer Secret: ').strip()
at = input('Enter your Access Token: ').strip()
ats = input('Enter your Access Token Secret: ').strip()
jsondata= {"consumer_key": ck,
"consumer_secret": cs,
"access_token": at,
"access_token_secret": ats}
with open(home+"/.twweet-cli/data/creds.json", "w") as outfile:
json.dump(jsondata, outfile)
os.chmod(home+"/.twweet-cli/data/creds.json", 0o777)
setup(
name='twweet_cli',
version='1.0.0',
description='Tweet right from your cli without even opening your browser.',
long_description=long_description,
url='https://github.com/CruiseDevice/twweet-cli/',
author='Akash Chavan',
author_email='achavan1211@gmail.com',
license='MIT',
classifiers=[
'Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.6',
],
cmdclass={
'install': TwtApiDetails,
},
keywords='twitter tweet cli',
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
install_requires=[
'tweepy',
'pyyaml'
],
py_modules=["twweet_cli"],
entry_points={
'console_scripts': [
'twweet-cli = main:cli',
],
},
)