
import requests
from requests.auth import HTTPBasicAuth
from datetime import datetime
from tkinter import messagebox
import pytz
import subprocess
import os
import sys
from tkinter import *
root=Tk()
root.geometry('300x300')
root.title('ACBackup - powerd by ')
a = Label(root, text="Welcome to AC Backup")
a.pack()
#def backup():
# os.system('backup.py')
# Create a Button
btn = Button(root, text='Start Backup', bd='5', command=response)
# Set the position of button on the top of window.
btn.pack(side='top')
##IGNORE SSL WARNING###
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
#######################
###GETTING TIME IN IST FORMAT####
IST = pytz.timezone('Europe/Berlin')
datetime_ist = datetime.now(IST)
current_datetime = datetime_ist.strftime('%d%m%Y_%H%M')
#######################
##AUDIOCODES SBC IP ADDRESS##
url = "192.168.12.245"
#######################
###MAKING GET REQUEST###
response = requests.get('https://' + url + '/api/v1/files/ini', auth=HTTPBasicAuth('Admin', '12345'), verify=False)
if response.status_code == 200:
with open(url + "_" + current_datetime + "_backup.ini", "w") as f:
f.write(response.text)
f.close()
print("Successfully backed up the INI file")
messagebox.showinfo("Backup Erfolgreich", 'Successfully backed up the INI file')
else:
print("Backup has been failed with an error status of", response.status_code)
print("Error Description is: ", response.text)
root.mainloop()