class Controller: def __init__(self): self.database = Database() pass def show_login(self, username): self.login = LoginWindow(self.database, username) self.login.switchNewUser.connect(self.show_userRegister) self.login.switchNewBusiness.connect(self.show_businessRegistration) self.login.switchDashboard.connect(self.show_dashboard) self.login.window.show() def show_userRegister(self): self.uRegister = UserRegisterWindow(self.database) self.uRegister.switchLogin.connect(self.show_login) self.login.window.close() self.uRegister.window.show() def show_dashboard(self, username): self.dashboard = Dashboard(self.database, username) self.dashboard.switchAddProject.connect(self.show_addProject) self.dashboard.switchAddDelivery.connect(self.show_addDelivery) self.dashboard.switchInventoryInsert.connect(self.show_itemSearch) self.dashboard.window.showFullScreen() # self.bRegister.window.close() def show_businessRegistration(self, username): self.bRegister = BusinessRegisterWindow(self.database, username) self.login.window.close() self.bRegister.switchDashboard.connect(self.show_dashboard) self.bRegister.window.show() def show_addProject(self, companyName): self.addProjectWin = AddProject(self.database, companyName) self.addProjectWin.switchDashboard.connect(self.updateDashboardUI) self.addProjectWin.window.show() def updateDashboardUI(self, source): self.dashboard.updateUI(source) def show_addDelivery(self): self.addDeliveryPref = AddDelivery(self.database) self.addDeliveryPref.switchDashboardOM.connect(self.updateDashboardUI) self.addDeliveryPref.window.show() def show_itemSearch(self): self.itemSearch = ItemSearch(self.database) self.itemSearch.switchDashboard.connect(self.updateItemTable) self.itemSearch.window.show() def updateItemTable(self, itemId): self.dashboard.addToItemTable(itemId)
def __init__(self): super(MainWindow, self).__init__() self.user = Connection() self.setMinimumSize(1200, 800) base_dir = os.path.dirname(os.path.abspath(__file__)) path = os.path.join(base_dir, 'images') self.home_path = os.path.join(path, 'docker_image_16.png') self.containers_path = os.path.join(path, 'containers_icon.png') self.images_path = os.path.join(path, 'images_icon.png') self.volumes_path = os.path.join(path, 'volumes_icon.png') self.dashboard_path = os.path.join(path, 'dashboard_icon.png') # create side menu self.listView = QListWidget() self.listView.setMaximumWidth(140) self.listView.itemSelectionChanged.connect(self.on_selection_changed) self.listView.ScrollMode(False) self.stack = QStackedWidget(self) # add widget of each page here # home dashboard stack service container images volume self.homepage = Homepage() self.dashboard = Dashboard(len(self.user.getContainersDetail()), self.user.getNumberOfImageList(), self.user.getNumberOfVolumeList(), self.listView) self.container = Container(self.user) self.images = Image(self.user) self.volumes = Volume(self.user) # self.log = Log('text.txt') self.stack.addWidget(self.homepage) self.stack.addWidget(self.dashboard) self.stack.addWidget(self.container) self.stack.addWidget(self.images) self.stack.addWidget(self.volumes) self.layout = QHBoxLayout(self) self.layout.setAlignment(Qt.AlignTop) self.layout.addWidget(self.listView) self.layout.addWidget(self.stack) self.setLayout(self.layout) self.setupMenu()
def LoginButtonfunction(): User = Person() User.Username = UsernameField.get("1.0", END) User.Password = passwordField.get("1.0", END) if len(User.Username) - 1 != 0 and len(User.Password) - 1 != 0: Data = User.Login(User.Username, User.Password) if Data[0] and Data[1].Authorize: if not Data[1].Admin: User = Users() else: User = Admin() User.Username = Data[1].Username User.Password = Data[1].Password User.Folderpath = Data[1].Folderpath User.Authorize = Data[1].Authorize User.Admin = Data[1].Admin if not User.Admin: root.destroy() root.quit() from Dashboard import Dashboard next = Dashboard(User) else: pass # الى هيعمل ال admin else: tkinter.messagebox.showinfo(" Invalid Credintial", "User Doesnot exist thank you :)") root.destroy() root.quit() else: tkinter.messagebox.showinfo("Empty fields", "Do net leave any field empty ")
def start(self, args): self.zabbix = Zabbix(args['zabbix']) self.server = Dashboard(args['dashboard']) self.lldpctl = LldpCtl(args['discovery']) self.namespaces = args['namespaces'] self.check = args['check'] self.delay = args['delay'] # Запуск функции run из родительского класса ProcessLauncher self.run()
def toDashboard(self): self.ui = Dashboard() self.ui.setOptionsMenu(self.toMenu, self.toRegulatedData, self.toGraph, self.toSearchByWord, self.toDashboard, self.toAllData, self.toResidenceBigData, self.toProcessesBigData, self.toResidenceAndProcessesBigData, self.toDataInventary) self.MainWindow.move(600, 100) self.ui.setupUi(self.MainWindow)
def get_object(page_name): page_obj = None page_name = page_name.lower() if page_name == "loginpage": page_obj = LoginPage() elif page_name == "rename": page_obj = Rename() elif page_name == "dashboard": page_obj = Dashboard() elif page_name == "accountpage": page_obj = AccountPage() return page_obj
def on_login_click(self): """check for if input fields are empty or not then verify the user id and password and then logged into the system""" username = self.un.get() password = self.pw.get() valid = Staff() if username == "" or password == "": messagebox.showerror("Error", "Enter all values") else: usr = valid.login(username, password) if len(usr) > 0: self.root.destroy() Dashboard(usr[0]) else: messagebox.showerror('Error', 'Wrong id or password')
def login(self): if(self.usernameText.get() == "" or self.passwordText.get() == ""): messagebox.showerror('Login Error', 'Please enter username and password') return None sql = "SELECT * FROM users WHERE username = '******' AND password = '******'".format(self.usernameText.get(), self.passwordText.get()) cursor.execute(sql) result = cursor.fetchall() if(len(result) == 0): messagebox.showerror('Wrong credentials','Wrong username or password') return None self.window.withdraw() dashboard = Dashboard(username= result[0]['username'],user_id= result[0]['user_id'])
def LoginButtonfunction(): if passwordField.get("1.0", END) == User.Password and len( NewpasswordField.get( "1.0", END)) >= 9 and NewpasswordField.get( "1.0", END) == reenternewpasswordField.get( "1.0", END): try: User.Changepassword(NewpasswordField.get("1.0", END)) root.destroy() root.quit() from Dashboard import Dashboard next = Dashboard(User) except: tkinter.messagebox.showinfo("Error", "Operation failed try later") root.destroy() root.quit() else: tkinter.messagebox.showinfo("Invalid Passwords", "Passwords are Invalid") root.destroy() root.quit()
def __init__(self): super(MainWindow, self).__init__() self.user = User() self.setMinimumSize(1200 ,800) #create side menu self.listView = QListWidget() self.listView.setMaximumWidth(140) self.listView.itemSelectionChanged.connect(self.on_selection_changed) self.listView.ScrollMode(False) self.stack = QStackedWidget (self) # add widget of each page here # home dashboard stack service container images volume self.homepage = Homepage() self.dashboard = Dashboard(1 ,2 ,3, self.listView) self.container = Container() self.images = ListImages(self.user) self.volumes = VolumeList(self.user) # self.log = Log('text.txt') self.stack.addWidget (self.homepage) self.stack.addWidget (self.dashboard) self.stack.addWidget (self.container) self.stack.addWidget (self.images) self.stack.addWidget (self.volumes) self.layout = QHBoxLayout(self) self.layout.setAlignment(Qt.AlignTop) self.layout.addWidget(self.listView) self.layout.addWidget(self.stack) self.setLayout(self.layout) self.setupMenu()
def Submitbuttonfunction(): User = Users() if len(passwordField.get("1.0", END)) >= 8 and passwordField.get( "1.0", END) == reenterpasswordField.get( "1.0", END) and len(UsernameField.get("1.0", END)) != 0: User.Username = str(UsernameField.get("1.0", END)) User.Password = str(passwordField.get("1.0", END)) try: User.Register() root.destroy() root.quit() from Dashboard import Dashboard next = Dashboard(User) except: tkinter.messagebox.showinfo( "invalid Credentials", "Do net leave any field empty and may be your user name used before" ) else: tkinter.messagebox.showinfo( "weak password", "Enter strong Password or password doesnot seem to be exactly" )
def __init__(self): self._ignition_system = IgnitionSystem() self._engine = Engine() self._tank = FuelTank() self._dashboard = Dashboard()
class CarFacade(object): def __init__(self): self._ignition_system = IgnitionSystem() self._engine = Engine() self._tank = FuelTank() self._dashboard = Dashboard() @property def kmpl(self): # km per liter return 17.0 def burn_fuel(self, km): liters = min(self._tank.fuel, km / self.kmpl) self._tank.fuel -= liters def start(self): print('Starting engine...') self._dashboard.view if self._ignition_system.produce_spark(): self._engine.on() else: print('Can\'t start engine; fault ignition system!') def has_enough_fuel(self, km , kmpl): return (self._tank.fuel >= (km / kmpl)) def drive(self, km=100): if self._engine.rpm > 0: while (self.has_enough_fuel(km, self.kmpl)): self.burn_fuel(km) print(f'Drove { km }km! {self._tank.fuel:.2f}L of fuel remaining.') else: print(f'Please turn on the Engine before attempting to drive!') def park(self): print('Parking...') self._dashboard.set_lights_status('handbrake', False) self._dashboard.view self._engine.off() def fill_tank(self): self._tank.fuel = 100 def toggle_fogs(self): print('Toggling Fog Lights') self._dashboard.toggle_lights('fog') def toggle_handbrakes(self): print('Toggling Handbrake Lights') self._dashboard.toggle_lights('handbrakes') def toggle_dashboard(self): print('Toggling All Lights') self._dashboard.toggle_lights() def __repr__(self): return (f'Car:\n * { self._ignition_system }' f'\n * { self._engine }' f'\n * { self._tank }' f'\n * { self._dashboard }')
def __init__(self): super().__init__() self.setBackgroundBrush(QBrush(QPixmap(':/images/background.png'))) self.skill_label = self.addSimpleText(Config.UserName, Config.BigFont) self.skill_label.setPos(-400, -100) self.photos = list() group = QParallelAnimationGroup(self) for i in range(7): photo = Photo() self.photos.append(photo) self.addItem(photo) x = i * photo.boundingRect().width() + Config.Rect.x() y = Config.Rect.y() + 10 duration = 1500.0 * qrand() / RAND_MAX translation = QPropertyAnimation(photo, bytes("pos", 'utf-8')) translation.setEndValue(QPointF(x, y)) translation.setEasingCurve(QEasingCurve.OutBounce) translation.setDuration(duration) group.addAnimation(translation) self.photos[0].loadAvatar("generals/small/caocao.png") self.photos[1].loadAvatar("generals/small/liubei.png") self.photos[2].loadAvatar("generals/small/sunquan.png") self.photos[3].loadAvatar("generals/small/simayi.png") self.photos[4].loadAvatar("generals/small/guojia.png") self.photos[5].loadAvatar("generals/small/zhugeliang.png") self.photos[6].loadAvatar("generals/small/zhouyu.png") self.dashboard = Dashboard() self.dashboard.setGeneral(General("caocao", "wei", 4, True)) self.addItem(self.dashboard) start_pos = Config.Rect.topLeft() end_pos = QPointF( Config.Rect.x(), Config.Rect.bottom() - self.dashboard.boundingRect().height()) duration = 1500 translation = QPropertyAnimation(self.dashboard, bytes("pos", 'utf-8')) translation.setStartValue(start_pos) translation.setEndValue(end_pos) translation.setEasingCurve(QEasingCurve.OutBounce) translation.setDuration(duration) enlarge = QPropertyAnimation(self.dashboard, bytes("scale", 'utf-8')) enlarge.setStartValue(0.2) enlarge.setEndValue(1.0) enlarge.setEasingCurve(QEasingCurve.OutBounce) enlarge.setDuration(duration) group.addAnimation(translation) group.addAnimation(enlarge) group.start(QAbstractAnimation.DeleteWhenStopped) card1 = Card("savage_assault", Card.Spade, 1) card2 = Card("slash", Card.Club, 7) card3 = Card("jink", Card.Heart, 2) card4 = Card("peach", Card.Diamond, 10) card5 = Card("archery_attack", Card.Heart, 11) card6 = Card("crossbow", Card.Club, 12) self.dashboard.addCard(card1) self.dashboard.addCard(card2) self.dashboard.addCard(card3) self.dashboard.addCard(card4) self.dashboard.addCard(card5) self.dashboard.addCard(card6) card4.setEnabled(False)
class Statistics(ProcessLauncher): def __init__(self): self.type = 'statistics' def start(self, args): self.zabbix = Zabbix(args['zabbix']) self.server = Dashboard(args['dashboard']) self.lldpctl = LldpCtl(args['discovery']) self.namespaces = args['namespaces'] self.check = args['check'] self.delay = args['delay'] # Запуск функции run из родительского класса ProcessLauncher self.run() # Отправка статистики def single(self, ns): self.signal() self.lldpctl.start() # Время на инициализацию LLDP time.sleep(5) while True: self.location = self.lldpctl.get_location() for i in self.results.keys(): res = self.results.get(i, 'NONE') if res != 'NONE': if res['type'] == 'dhcp' and res['ns'] == ns: dhcp_state = res.get('state', 'NONE') dhcp_time = res.get('time', None) if dhcp_state == 'OK' and dhcp_time > 30: dhcp_state = 'WARN' try: if dhcp_state != 'RUN': self.zabbix.send(self.location, res['type'] + '.' + res['ns'], dhcp_time) self.server.send_data({ 'location': self.location, 'service': ns, 'check' : res['check'], 'value': dhcp_state }) except Exception as e: logging.info("[Statistics] Generic exception: %s" % str(e)) elif res['type'] == 'ping' and res['ns'] == ns: ping_state = res.get('state', 'NONE') ping_max_rtt = res.get('max_rtt', None) ping_avg_rtt = res.get('avg_rtt', None) ping_min_rtt = res.get('min_rtt', None) ping_packet_lost = res.get('packet_lost', None) if ping_state == 'OK' and (ping_packet_lost != 0 or float(ping_avg_rtt) > 200): ping_state = 'WARN' try: if ping_state != 'RUN': self.zabbix.send(self.location, res['type'] + '.time.' + res['ns'] + '[' + res['check'] + ']', ping_avg_rtt) self.zabbix.send(self.location, res['type'] + '.lost.' + res['ns'] + '[' + res['check'] + ']', ping_packet_lost) self.server.send_data({ 'location': self.location, 'service': ns, 'check' : res['check'], 'value' : ping_state }) except Exception as e: logging.info("[Statistics] Generic exception: %s" % str(e)) elif res['type'] == 'dns' and res['ns'] == ns: dns_state = res.get('state', 'NONE') dns_qtime = res.get('qtime', None) if dns_state == 'OK' and float(dns_qtime) > 200: dns_state = 'WARN' try: if dns_state != 'RUN': self.zabbix.send(self.location, res['type'] + '.' + res['ns'], dns_qtime) self.server.send_data({ 'location': self.location, 'service': ns, 'check' : res['check'], 'value': dns_state }) except Exception as e: logging.info("[Statistics] Generic exception: %s" % str(e)) elif res['type'] == 'http' and res['ns'] == ns: http_state = res.get('state', 'NONE') http_code = res.get('code', None) http_time = res.get('time', None) http_speed = res.get('speed', None) http_size = res.get('size', None) if http_state == 'OK' and float(http_time) > 5: http_state = 'WARN' try: if http_state != 'RUN': self.zabbix.send(self.location, res['type'] + '.time.' + res['ns'] + '[' + res['check'] + ']', http_time) self.zabbix.send(self.location, res['type'] + '.speed.' + res['ns'] + '[' + res['check'] + ']', http_speed) self.server.send_data({ 'location': self.location, 'service': ns, 'check' : res['check'], 'value': http_state }) except Exception as e: logging.info("[Statistics] Generic exception: %s" % str(e)) elif res['type'] == 'rzs' and res['ns'] == ns: rzs_state = res.get('state', 'NONE') rzs_total = res.get('rzs_total', None) rzs_available = res.get('rzs_available', None) rzs_unavailable = res.get('rzs_unavailable', None) if rzs_state == 'OK' and (float(rzs_available)/float(rzs_total) > 0.1): rzs_state = 'WARN' if rzs_state == 'OK' and (float(rzs_available)/float(rzs_total) > 0.3): rzs_state = 'FAIL' try: if rzs_state != 'RUN': self.zabbix.send(self.location, res['type'] + '.total.' + res['ns'], rzs_total) self.zabbix.send(self.location, res['type'] + '.available.' + res['ns'], rzs_available) self.zabbix.send(self.location, res['type'] + '.unavailable.' + res['ns'], rzs_unavailable) self.server.send_data({ 'location': self.location, 'service': ns, 'check' : res['check'], 'value': rzs_state }) except Exception as e: logging.info("[Statistics] Generic exception: %s" % str(e)) time.sleep(float(self.delay))
def show_dashboard(self, username): self.dashboard = Dashboard(self.database, username) self.dashboard.switchAddProject.connect(self.show_addProject) self.dashboard.switchAddDelivery.connect(self.show_addDelivery) self.dashboard.switchInventoryInsert.connect(self.show_itemSearch) self.dashboard.window.showFullScreen()
class MainWindow(QWidget): def __init__(self): super(MainWindow, self).__init__() self.user = Connection() self.setMinimumSize(1200, 800) base_dir = os.path.dirname(os.path.abspath(__file__)) path = os.path.join(base_dir, 'images') self.home_path = os.path.join(path, 'docker_image_16.png') self.containers_path = os.path.join(path, 'containers_icon.png') self.images_path = os.path.join(path, 'images_icon.png') self.volumes_path = os.path.join(path, 'volumes_icon.png') self.dashboard_path = os.path.join(path, 'dashboard_icon.png') # create side menu self.listView = QListWidget() self.listView.setMaximumWidth(140) self.listView.itemSelectionChanged.connect(self.on_selection_changed) self.listView.ScrollMode(False) self.stack = QStackedWidget(self) # add widget of each page here # home dashboard stack service container images volume self.homepage = Homepage() self.dashboard = Dashboard(len(self.user.getContainersDetail()), self.user.getNumberOfImageList(), self.user.getNumberOfVolumeList(), self.listView) self.container = Container(self.user) self.images = Image(self.user) self.volumes = Volume(self.user) # self.log = Log('text.txt') self.stack.addWidget(self.homepage) self.stack.addWidget(self.dashboard) self.stack.addWidget(self.container) self.stack.addWidget(self.images) self.stack.addWidget(self.volumes) self.layout = QHBoxLayout(self) self.layout.setAlignment(Qt.AlignTop) self.layout.addWidget(self.listView) self.layout.addWidget(self.stack) self.setLayout(self.layout) self.setupMenu() def setupMenu(self): imageList = [ self.home_path, self.dashboard_path, self.containers_path, self.images_path, self.volumes_path ] menuList = ['HOME', 'DASHBOARD', 'CONTAINERS', 'IMAGES', 'VOLUMES'] for i in range(len(menuList)): itm = QListWidgetItem(menuList[i]) itm.setIcon(QIcon(imageList[i])) self.listView.addItem(itm) def on_selection_changed(self): index = self.listView.currentRow() if index == 1: self.dashboard.setup(len(self.user.getContainersDetail()), self.user.getNumberOfImageList(), self.user.getNumberOfVolumeList()) self.stack.setCurrentIndex(index)
def Cancelbuttonfunction(): root.destroy() root.quit() next = Dashboard(User)
def CancelButtonfunction(): root.destroy() root.quit() from Dashboard import Dashboard next = Dashboard(User)