From 5440c83848296426a7ae0b70e58214899675f292 Mon Sep 17 00:00:00 2001 From: Alfonso De Cala Bravo Date: Tue, 23 Feb 2021 12:55:17 +0100 Subject: [PATCH] Even more fixes for Python 3.5 compatibility --- sessionManager.py | 6 +++--- telegram-download-daemon.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sessionManager.py b/sessionManager.py index 5d8a53e..64bba53 100644 --- a/sessionManager.py +++ b/sessionManager.py @@ -3,7 +3,7 @@ from telethon.sessions import StringSession TELEGRAM_DAEMON_SESSION_PATH = getenv("TELEGRAM_DAEMON_SESSION_PATH") sessionName = "DownloadDaemon" -stringSessionFilename = f"{sessionName}.session" +stringSessionFilename = "{0}.session".format(sessionName) def _getStringSessionIfExists(): @@ -12,7 +12,7 @@ def _getStringSessionIfExists(): if path.isfile(sessionPath): with open(sessionPath, 'r') as file: session = file.read() - print(f"Session loaded from {sessionPath}") + print("Session loaded from {0}".format(sessionPath)) return session return None @@ -30,4 +30,4 @@ def saveSession(session): stringSessionFilename) with open(sessionPath, 'w') as file: file.write(StringSession.save(session)) - print(f"Session saved in {sessionPath}") + print("Session saved in {0}".format(sessionPath)) diff --git a/telegram-download-daemon.py b/telegram-download-daemon.py index 4389985..fb7de20 100644 --- a/telegram-download-daemon.py +++ b/telegram-download-daemon.py @@ -148,7 +148,7 @@ with TelegramClient(getSession(), api_id, api_hash, output = "Unknown command" 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": try: 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." elif command == "clean": 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: output = "Available commands: list, status, clean"