mirror of
https://github.com/alfem/telegram-download-daemon.git
synced 2024-09-20 06:46:05 +08:00
Even more fixes for Python 3.5 compatibility
This commit is contained in:
parent
7532edc2e7
commit
5440c83848
|
@ -3,7 +3,7 @@ from telethon.sessions import StringSession
|
||||||
|
|
||||||
TELEGRAM_DAEMON_SESSION_PATH = getenv("TELEGRAM_DAEMON_SESSION_PATH")
|
TELEGRAM_DAEMON_SESSION_PATH = getenv("TELEGRAM_DAEMON_SESSION_PATH")
|
||||||
sessionName = "DownloadDaemon"
|
sessionName = "DownloadDaemon"
|
||||||
stringSessionFilename = f"{sessionName}.session"
|
stringSessionFilename = "{0}.session".format(sessionName)
|
||||||
|
|
||||||
|
|
||||||
def _getStringSessionIfExists():
|
def _getStringSessionIfExists():
|
||||||
|
@ -12,7 +12,7 @@ def _getStringSessionIfExists():
|
||||||
if path.isfile(sessionPath):
|
if path.isfile(sessionPath):
|
||||||
with open(sessionPath, 'r') as file:
|
with open(sessionPath, 'r') as file:
|
||||||
session = file.read()
|
session = file.read()
|
||||||
print(f"Session loaded from {sessionPath}")
|
print("Session loaded from {0}".format(sessionPath))
|
||||||
return session
|
return session
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -30,4 +30,4 @@ def saveSession(session):
|
||||||
stringSessionFilename)
|
stringSessionFilename)
|
||||||
with open(sessionPath, 'w') as file:
|
with open(sessionPath, 'w') as file:
|
||||||
file.write(StringSession.save(session))
|
file.write(StringSession.save(session))
|
||||||
print(f"Session saved in {sessionPath}")
|
print("Session saved in {0}".format(sessionPath))
|
||||||
|
|
|
@ -148,7 +148,7 @@ with TelegramClient(getSession(), api_id, api_hash,
|
||||||
output = "Unknown command"
|
output = "Unknown command"
|
||||||
|
|
||||||
if command == "list":
|
if command == "list":
|
||||||
output = subprocess.run(["ls -l "+downloadFolder], shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT,encoding="utf-8").stdout
|
output = subprocess.run(["ls -l "+downloadFolder], shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.decode('utf-8')
|
||||||
elif command == "status":
|
elif command == "status":
|
||||||
try:
|
try:
|
||||||
output = "".join([ "{0}: {1}\n".format(key,value) for (key, value) in in_progress.items()])
|
output = "".join([ "{0}: {1}\n".format(key,value) for (key, value) in in_progress.items()])
|
||||||
|
@ -160,7 +160,7 @@ with TelegramClient(getSession(), api_id, api_hash,
|
||||||
output = "Some error occured while checking the status. Retry."
|
output = "Some error occured while checking the status. Retry."
|
||||||
elif command == "clean":
|
elif command == "clean":
|
||||||
output = "Cleaning "+tempFolder+"\n"
|
output = "Cleaning "+tempFolder+"\n"
|
||||||
output+=subprocess.run(["rm "+tempFolder+"/*."+TELEGRAM_DAEMON_TEMP_SUFFIX], shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT,encoding="utf-8").stdout
|
output+=subprocess.run(["rm "+tempFolder+"/*."+TELEGRAM_DAEMON_TEMP_SUFFIX], shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout
|
||||||
else:
|
else:
|
||||||
output = "Available commands: list, status, clean"
|
output = "Available commands: list, status, clean"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue