mirror of
https://github.com/KevinMidboe/transatlanticTorrentExpress.git
synced 2025-10-29 01:40:21 +00:00
Avg speed file should return integer or None
This commit is contained in:
16
utils.py
16
utils.py
@@ -4,6 +4,7 @@ from configparser import RawConfigParser, NoOptionError
|
||||
|
||||
pwd = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
AVG_SPEED_FILE = '.avgspeed.txt'
|
||||
VIDEO_EXTENSIONS = ('.3g2', '.3gp', '.3gp2', '.3gpp', '.60d', '.ajp', '.asf', '.asx', '.avchd', '.avi', '.bik',
|
||||
'.bix', '.box', '.cam', '.dat', '.divx', '.dmf', '.dv', '.dvr-ms', '.evo', '.flc', '.fli',
|
||||
'.flic', '.flv', '.flx', '.gvi', '.gvp', '.h264', '.m1v', '.m2p', '.m2v', '.m4e',
|
||||
@@ -35,20 +36,23 @@ def getConfig():
|
||||
return config
|
||||
|
||||
def writeAvgSpeedToDisk(speed):
|
||||
path = os.path.join(pwd, '.avgspeed.txt')
|
||||
path = os.path.join(pwd, AVG_SPEED_FILE)
|
||||
|
||||
with open(path, 'w') as f:
|
||||
f.write(str(int(speed or 100)))
|
||||
f.write(str(int(speed)))
|
||||
f.close()
|
||||
|
||||
def readAvgSpeedFromDisk():
|
||||
path = os.path.join(pwd, '.avgspeed.txt')
|
||||
path = os.path.join(pwd, AVG_SPEED_FILE)
|
||||
|
||||
with open(path, 'r') as f:
|
||||
data = f.readline()
|
||||
f.close()
|
||||
|
||||
if data == '':
|
||||
data = '1'
|
||||
speed = None
|
||||
try:
|
||||
speed = int(data)
|
||||
except:
|
||||
pass
|
||||
|
||||
return int(data)
|
||||
return speed
|
||||
|
||||
Reference in New Issue
Block a user