Skip to content

Commit

Permalink
fixed update check
Browse files Browse the repository at this point in the history
  • Loading branch information
SevenChords committed Jul 19, 2020
1 parent 9922bab commit ff032ce
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 53 deletions.
110 changes: 58 additions & 52 deletions FTPManagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,59 +9,65 @@
ftp.cwd("htdocs/roadmap")

def getFastestRecordOnFTP():
ftp = FTP("ftp.byethost7.com")
ftp.login("b7_26300774", "Wxu8dLdV2/")
ftp.cwd("htdocs/roadmap/results")
files = []
try:
files = ftp.nlst()
files.pop(0)
files.pop(0)
temp = files[0]
except:
log(0, "FTP", "List", "Read", "CRITICAL: No files found. Creating empty [9999].txt")
file = open("results/[9999].txt", "w")
file.write("temp file\n")
file.close()
with open("results/[9999].txt", "rb") as localFile:
ftp.storlines("STOR %s" % "[9999].txt", localFile)
localFile.close()
files = ftp.nlst()
files.pop(0)
files.pop(0)
temp = files[0]
records = []
for file in files:
record = int(re.findall("\[([^\s\]]*)\]", file)[0])
records.append(record)
records.sort()
ftp.quit()
return records[0]
ftp = FTP("ftp.byethost7.com")
ftp.login("b7_26300774", "Wxu8dLdV2/")
ftp.cwd("htdocs/roadmap/results")
files = []
try:
files = ftp.nlst()
files.pop(0)
files.pop(0)
temp = files[0]
except:
log(0, "FTP", "List", "Read", "CRITICAL: No files found. Creating empty [9999].txt")
file = open("results/[9999].txt", "w")
file.write("temp file\n")
file.close()
with open("results/[9999].txt", "rb") as localFile:
ftp.storlines("STOR %s" % "[9999].txt", localFile)
localFile.close()
files = ftp.nlst()
files.pop(0)
files.pop(0)
temp = files[0]
records = []
for file in files:
record = int(re.findall("\[([^\s\]]*)\]", file)[0])
records.append(record)
records.sort()
ftp.quit()
return records[0]

def testRecord(value):
remoteRecord = getFastestRecordOnFTP()
localRecord = value
ftp = FTP("ftp.byethost7.com")
ftp.login("b7_26300774", "Wxu8dLdV2/")
ftp.cwd("htdocs/roadmap/results")
if(localRecord <= remoteRecord):
with open("results/[" + str(localRecord) + "].txt", "rb") as localFile:
ftp.storlines("STOR %s" % "[" + str(localRecord) + "]_" + getConfig("Username") + ".txt", localFile)
localFile.close()
log(1, "FTP", "File", "Upload", "File [" + str(localRecord) + "].txt has been uploaded.")
ftp.quit()
remoteRecord = getFastestRecordOnFTP()
localRecord = value
ftp = FTP("ftp.byethost7.com")
ftp.login("b7_26300774", "Wxu8dLdV2/")
ftp.cwd("htdocs/roadmap/results")
if(localRecord <= remoteRecord):
with open("results/[" + str(localRecord) + "].txt", "rb") as localFile:
ftp.storlines("STOR %s" % "[" + str(localRecord) + "]_" + getConfig("Username") + ".txt", localFile)
localFile.close()
log(1, "FTP", "File", "Upload", "File [" + str(localRecord) + "].txt has been uploaded.")
ftp.quit()

def checkForUpdates()
log(0, "Update", "Check", "", "Checking for updates...")
ftp = FTP("ftp.byethost7.com")
ftp.login("b7_26300774", "Wxu8dLdV2/")
ftp.cwd("htdocs/roadmap")
try:
files = ftp.nlst()
if("[update].txt" in files):
log(0, "Update", "Check", "", "Newer version found, please download the newest release from github.")
input()
raise
except:
sys.exit()
log(0, "Update", "Check", "", "You are running the newest release of this script.\nHappy calculation time!")
log(0, "Update", "Check", "", "Checking for updates...")
ftp = FTP("ftp.byethost7.com")
ftp.login("b7_26300774", "Wxu8dLdV2/")
ftp.cwd("htdocs/roadmap/version")
try:
files = ftp.nlst()
files.pop(0)
files.pop(0)
remoteVersion = str(re.findall("\[([^\s\]]*)\]", files[0])[0])
localVersion = getConfig("Version")
if(remoteVersion == localVersion):
log(0, "Update", "Check", "", "You are running the newest release of this script.\nHappy calculation time!")
return null
else:
log(0, "Update", "Check", "", "You are running the wrong version of this script, please get the newest release from github.")
inpu()
sys.exit()
except:
raise
4 changes: 4 additions & 0 deletions config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,8 @@
# Your username under which your records are #
# Uploaded to the remote server #
# [Username = DefaultUser] #
###############################################

###############################################
# [Version = 2.3.1] #
###############################################
2 changes: 1 addition & 1 deletion start.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def work(startingInventory, recipeList, invFrames):
invFrames = getInventoryFrames()
workerCount = int(getConfig("workerCount"))
while(True):
checkForUpdates()
checkForUpdates()
currentFrameRecord = getFastestRecordOnFTP()
#start the work
result = work(startingInventory, recipeList, invFrames)
Expand Down

0 comments on commit ff032ce

Please sign in to comment.