File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -88,18 +88,23 @@ def getConfig(name: str):
8888 MEGA_KEY = None
8989 LOGGER .info ('MEGA API KEY NOT AVAILABLE' )
9090if MEGA_KEY is not None :
91+ # Start megasdkrest binary
92+ subprocess .Popen (["megasdkrest" , "--apikey" , MEGA_KEY ])
93+ time .sleep (3 ) # Wait for the mega server to start listening
94+ mega_client = MegaSdkRestClient ('http://localhost:6090' )
9195 try :
9296 MEGA_USERNAME = getConfig ('MEGA_USERNAME' )
9397 MEGA_PASSWORD = getConfig ('MEGA_PASSWORD' )
94- # Start megasdkrest binary
95- subprocess .Popen (["megasdkrest" , "--apikey" , MEGA_KEY ])
96- time .sleep (3 )
97- mega_client = MegaSdkRestClient ('http://localhost:6090' )
98- try :
99- mega_client .login (MEGA_USERNAME , MEGA_PASSWORD )
100- except mega_err .MegaSdkRestClientException as e :
101- logging .error (e .message ['message' ])
102- exit (0 )
98+ if len (MEGA_USERNAME ) > 0 and len (MEGA_PASSWORD ) > 0 :
99+ try :
100+ mega_client .login (MEGA_USERNAME , MEGA_PASSWORD )
101+ except mega_err .MegaSdkRestClientException as e :
102+ logging .error (e .message ['message' ])
103+ exit (0 )
104+ else :
105+ LOGGER .info ("Mega API KEY provided but credentials not provided. Starting mega in anonymous mode!" )
106+ MEGA_USERNAME = None
107+ MEGA_PASSWORD = None
103108 except KeyError :
104109 LOGGER .info ("Mega API KEY provided but credentials not provided. Starting mega in anonymous mode!" )
105110 MEGA_USERNAME = None
You can’t perform that action at this time.
0 commit comments