-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
51 lines (40 loc) · 1.18 KB
/
main.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
43
44
45
46
47
48
49
50
51
from pytolino.tolino_cloud import Client, PytolinoException
import os
import sys
from dotenv import load_dotenv
import time
try:
load_dotenv()
username = os.environ.get('user')
password = os.environ.get('password')
except:
print("Please set your username and password in .env file")
time.sleep(5)
def main(file_path: str = None):
if file_path is None:
print("No file path provided.")
time.sleep(5)
file_extension = os.path.splitext(file_path)[1].lower()
client = Client()
client.login(username, password)
client.register()
client.upload(file_path, extension=file_extension)
client.unregister()
client.logout()
print("Done!")
def remove_quotes(string):
input_string = string
try:
if len(string) > 1 and (string[0] == '"' or string[0] == "'") and (string[-1] == '"' or string[-1] == "'"):
return string[1:-1]
else:
return string
except:
return input_string
if __name__ == "__main__":
try:
file_path = sys.argv[1]
except:
file_path = input("Enter file path: ")
file_path = remove_quotes(file_path)
main(file_path)