Skip to content
This repository has been archived by the owner on Oct 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2 from slimit75/development
Browse files Browse the repository at this point in the history
Finalize v1.0.0-alpha2
  • Loading branch information
slimit75 authored Sep 5, 2019
2 parents f16aeca + a0b6dac commit aa318c0
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 16 deletions.
6 changes: 3 additions & 3 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
file.close()

# Set static variables
version = "v1.0.0-alpha1"
version = "v1.0.0-alpha2"

# Set variables that need to be changed later
airline = "None"
Expand Down Expand Up @@ -82,8 +82,8 @@ def reloadList():
websites.append(config[key]['URL'])
savedAPIKeys.append(config[key]['apikey'])
usernames.append(config[key]['username'])
except Exception:
pass
except Exception as e:
print(e)

# Converts a string to a boolean. Used by no external files
def stringToBool(x):
Expand Down
100 changes: 93 additions & 7 deletions listAirlines.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,61 @@ def terminateEditAirline():
editAirWindow.quit()
return

## Closes the delete airline screen
def terminateDeleteAirline():
global airline
global delAirWindow

websites = configLib.websites
savedAPIKeys = configLib.savedAPIKeys
usernames = configLib.usernames
List = configLib.list

airline = airline.get()

a = List.index(airline)

config = configparser.ConfigParser()

no = """
if apiKey == "":
if username == "":
config[str(a+1)] = {'name': name, 'url': url}
else:
config[str(a+1)] = {'name': name, 'url': url, 'username': username}
else:
if username == "":
config[str(a+1)] = {'name': name, 'url': url, 'apikey': apiKey}
else:
config[str(a+1)] = {'name': name, 'url': url, 'apikey': apiKey, 'username': username}
"""

file = open('airlines.ini', 'r')
data = file.read()
file.close()

print(str(a+1))
data1 = data.split("[" + str(a) + "]")
print(data1[0])
try:
data2 = data1[1].split("[" + str(a+1) + "]")
print(data2[1])
except Exception as e:
print(e)
data2 = ["", ""]

with open('airlines.ini', 'w') as configfile:
configfile.write(data1[0])
#config.write(configfile)
if not data2[1] == "":
configfile.write("[" + str(a) + "]")
configfile.write(data2[1])
configfile.close()
config.write(configfile)

delAirWindow.quit()
return

## New airline screen
def new():
global name
Expand All @@ -115,7 +170,7 @@ def new():
global username

newAirWindow = tk.Tk()
window.iconbitmap('Favicon.ico')
newAirWindow.iconbitmap('Favicon.ico')
name = tk.StringVar(newAirWindow)
url = tk.StringVar(newAirWindow)
apiKey = tk.StringVar(newAirWindow)
Expand All @@ -135,8 +190,8 @@ def new():
newAirWindow.destroy()

configLib.reloadList()
window.quit()
window.destroy()
newAirWindow.quit()
newAirWindow.destroy()
reload()

## Autofill for the edit airline screen
Expand All @@ -160,6 +215,36 @@ def editAutofill():
if not usernames[a] == "None Saved":
username.set(usernames[a])

## Delete iarline screen
def delete():
global airline
global name
global url
global apiKey
global username
global delAirWindow

websites = configLib.websites
savedAPIKeys = configLib.savedAPIKeys
usernames = configLib.usernames
List = configLib.list

delAirWindow = tk.Tk()
delAirWindow.iconbitmap('Favicon.ico')
airline = tk.StringVar(delAirWindow)

delAirWindow.title('xACARS ' + configLib.version)
tk.Label(delAirWindow, text='Airline to delete: ').grid(row=0, column=0)
ttk.OptionMenu(delAirWindow, airline, *List).grid(row=0, column=1)
ttk.Button(delAirWindow, text='Update', command=terminateDeleteAirline).grid(row=1, columnspan=2, sticky='we')
delAirWindow.mainloop()
delAirWindow.destroy()

configLib.reloadList()
delAirWindow.quit()
delAirWindow.destroy()
reload()

## Edit screen
def edit():
global airline
Expand All @@ -175,7 +260,7 @@ def edit():
List = configLib.list

editAirWindow = tk.Tk()
window.iconbitmap('Favicon.ico')
editAirWindow.iconbitmap('Favicon.ico')
airline = tk.StringVar(editAirWindow)
name = tk.StringVar(editAirWindow)
url = tk.StringVar(editAirWindow)
Expand All @@ -199,8 +284,8 @@ def edit():
editAirWindow.destroy()

configLib.reloadList()
window.quit()
window.destroy()
editAirWindow.quit()
editAirWindow.destroy()
reload()

## Closes main menu
Expand Down Expand Up @@ -243,6 +328,7 @@ def reload():

ttk.Separator(window, orient=tk.HORIZONTAL).grid(row=a+3, columnspan=4, sticky="we")
ttk.Button(window, text='Finish', command=quit).grid(row=a+4, column=0, sticky="we")
ttk.Button(window, text='Add New', command=new).grid(row=a+4, column=1, sticky="we")
ttk.Button(window, text='Add Airline', command=new).grid(row=a+4, column=1, sticky="we")
ttk.Button(window, text='Edit Airline', command=edit).grid(row=a+4, column=2, sticky="we")
ttk.Button(window, text='Delete Airline', command=delete).grid(row=a+4, column=3, sticky="we")
window.mainloop()
16 changes: 10 additions & 6 deletions main.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,14 @@ def preFile():
"route_leg": str(data["flight"]["route_leg"]),
"dpt_airport_id": str(data["flight"]["dpt_airport_id"]),
"arr_airport_id": str(data["flight"]["arr_airport_id"]),
"level": str(cruiseAlt.get()),
"planned_distance": str(plannedDistance.get()),
"planned_flight_time": str(plannedFlightTime.get()),
"level": int(cruiseAlt.get()),
"planned_distance": int(plannedDistance.get()),
"planned_flight_time": int(plannedFlightTime.get()),
"route": str(route.get()),
"source_name": "xACARS",
"flight_type": str(data["flight"]["flight_type"])
}
}

data = json.dumps(data)
data = web.post(config.website + '/api/pireps/prefile', data)
data = json.loads(data.text)
Expand Down Expand Up @@ -204,7 +205,10 @@ def updateEnrouteTime():
ttk.Button(uetWindow, text='Save & Exit', command=uetWindow.quit).grid(row=3, columnspan=2, sticky="we")
uetWindow.mainloop()

# Update enroute time
newEnrouteTime = newEnrouteTime.get()
data = {"planned_flight_time": int(newEnrouteTime)}
print(data)
data = web.post(config.website + '/api/pireps/' + pirepID + '/update', data)

uetWindow.destroy()

Expand Down Expand Up @@ -264,7 +268,7 @@ def checkForUpdates():
Log('#######################################################')
Log("Checking for updates..")

data = web.get('https://raw.githubusercontent.com/slimit75/xACARS/installer/updates.json')
data = web.get('https://raw.githubusercontent.com/slimit75/xACARS/update-system/updates.json')
data = json.loads(data)

if config.getPreRel == True:
Expand Down

0 comments on commit aa318c0

Please sign in to comment.