-
Notifications
You must be signed in to change notification settings - Fork 2
/
monsoon.py
42 lines (34 loc) · 1.06 KB
/
monsoon.py
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
"""
monsoon.py
~~~~~~~~~~~~~~~~~~
Unlimited cloud storage
:copyright: (c) 2013 Raymond Jacobson
"""
import cli.app, os
from lib.db import decideNewAccount, getNewestAccount, getUploadedFile
from lib.dbox import uploadFileToAccount
from lib.generator import generateNewAccount
def put(file):
print "putting..."
if (decideNewAccount(os.stat(file).st_size)):
generateNewAccount()
account = getNewestAccount()
uploadFileToAccount(file, account['access_token'])
def grab(file):
print "grabbing..."
db_file = getUploadedFile(file)
print "pub link: " + db_file['short_link']
print "DL link: " + db_file['downloadable_link']
@cli.app.CommandLineApp
def monsoon(app):
if (app.params.action == 'put'):
put(app.params.file)
elif (app.params.action == 'grab'):
grab(app.params.file)
else:
print "invalid arguments. -h for help."
exit(1)
monsoon.add_param("action", help="either 'put' or 'grab' a file", default=1)
monsoon.add_param("file", help="file to commit action on", default=2)
if __name__ == "__main__":
monsoon.run()