Example #1
0
	def __init__(self, app):
		self.app = app
		self.layout = QHBoxLayout()

		self.textbox = QLineEdit(app)
		self.textbox.setText(os.path.abspath(Config.paths.scan))
		self.textbox.textChanged.connect(self.updatePath)
		self.layout.addWidget(self.textbox)

		self.scan = QPushButton('Scan', app)
		self.scan.clicked.connect(app.on_scan)
		self.layout.addWidget(self.scan)

		self.autolaunchBrowser = QCheckBox("Auto-Launch Web Browser?", app)
		self.autolaunchBrowser.setChecked(Config.autolaunchBrowser)
		self.autolaunchBrowser.stateChanged.connect(self.onCheck)
		self.layout.addWidget(self.autolaunchBrowser)

		self.serverInfo = QLabel("IP: %s  Port: %s  User: %s  Password: %s" % (getIpAddress(), str(Config.server.port), Users.first().id, Users.first().password))
		self.serverInfo.setFixedWidth(600)
		self.serverInfo.setAlignment(Qt.AlignCenter)

		self.layout.addWidget(self.serverInfo)
		self.usbStatus = QLabel("USB Status: " + str(Usb.status))

		self.usbStatus.setFixedWidth(200)

		self.layout.addWidget(self.usbStatus)

		self.timer = QTimer()
		self.timer.setInterval(1000)
		self.timer.timeout.connect(self.tick)
		self.timer.start()

		Users.export()
Example #2
0
    def tearDown(self):
        Config.paths.scan = self.paths_before_test
        Config.threads = self.threads_before_test
        Config.compression.level = self.compression_level_before_test
        Config.save()

        Users.users = self.users_before_test
        Users.export()
Example #3
0
	def saveUsers(self, control):
		result = {}
		i = 0
		while i < control.count():
			value = control.getValue(i)

			if value:
				result[value.id] = value
			i += 1

		Users.users = result
		Users.export()
Example #4
0
File: server.py Project: jasii/nut
    def __init__(self, app):
        self.app = app
        self.layout = QHBoxLayout()

        self.textbox = QLineEdit(app)
        self.textbox.setMinimumWidth(25)
        self.textbox.setAlignment(Qt.AlignLeft)
        self.textbox.setText(os.path.abspath(Config.paths.scan[0]))
        self.textbox.textChanged.connect(self.updatePath)
        self.layout.addWidget(self.textbox)

        self.scan = QPushButton('Scan', app)
        self.scan.clicked.connect(app.on_scan)
        self.layout.addWidget(self.scan)

        self.gdrive = QPushButton('Setup GDrive OAuth', app)
        self.gdrive.clicked.connect(app.on_gdrive)
        self.layout.addWidget(self.gdrive)

        # self.autolaunchBrowser = QCheckBox("Launch Web Browser?", app)
        # self.autolaunchBrowser.setChecked(Config.autolaunchBrowser)
        # self.autolaunchBrowser.stateChanged.connect(self.onCheck)
        # self.layout.addWidget(self.autolaunchBrowser)

        self.serverInfo = QLabel(
            "<b>IP:</b>  %s  <b>Port:</b>  %s  <b>User:</b>  %s  <b>Password:</b>  %s"
            % (getIpAddress(), str(
                Config.server.port), Users.first().id, Users.first().password))
        self.serverInfo.setMinimumWidth(200)
        self.serverInfo.setAlignment(Qt.AlignCenter)
        self.layout.addWidget(self.serverInfo)

        self.usbStatus = QLabel("<b>USB:</b>  " + str(Usb.status))
        self.usbStatus.setMinimumWidth(50)
        self.usbStatus.setAlignment(Qt.AlignCenter)
        self.layout.addWidget(self.usbStatus)

        self.timer = QTimer()
        self.timer.setInterval(1000)
        self.timer.timeout.connect(self.tick)
        self.timer.start()

        Users.export()
Example #5
0
    def __init__(self, parent, controller, cwd=None):
        self.controller = controller  #Controller (most toplevel parent)
        self.cwd = cwd or controller.cwd or sys.path[0]
        self.softwarelist = [
        ]  #list to hold software data to populate table and more
        self.currentselection = 0  #Variable to track currently selected software in listbox
        self.needsRefresh = True  #Variable to track if reload is needed

        width = 640
        height = 480
        minwidth = infoframewidth
        minheight = 120
        self.controller.geometry("{}x{}".format(width, height))
        self.controller.minsize(
            width=minwidth,
            height=minheight)  #minimum size currently supported
        self.controller.title("NUT")
        # self.controller.bind("<Configure>", self.reload)

        cw.ThemedFrame.__init__(self, parent)  #Init frame
        self.bind(
            "<<ShowFrame>>", self.on_show_frame
        )  #Bind on_show_frame to showframe event so whenever the frame is raised by the controller it reloads

        #Full window frame, holds everything
        self.outer_frame = cw.ThemedFrame(self,
                                          frame_borderwidth=0,
                                          frame_highlightthickness=0)
        self.outer_frame.place(relx=0.0, rely=0.0, relheight=1.0, relwidth=1.0)

        #Frame for main list, contains listboxes and scroll bar, and list titles
        self.content_frame = cw.ThemedFrame(self.outer_frame,
                                            frame_borderwidth=0,
                                            frame_highlightthickness=0)
        self.content_frame.place(
            relx=0.0,
            rely=0.0,
            relheight=1,
            relwidth=1,
            width=-infoframewidth,
        )
        self.content_frame.configure(background=dark_color)

        #The contents of this frame are built backwards when self.setbutton() is called due to needing to align the searchbox with the icons
        self.searchbox_frame = cw.ButtonRow(self.content_frame,
                                            frame_highlightthickness=0,
                                            background=light_color,
                                            frame_borderwidth=0)
        self.searchbox_frame.Place(
            relx=0.0,
            rely=0.0,
            height=searchboxheight,
            relwidth=1,
        )

        #Holds the scan path, hidden when not needed
        self.scanpathbox_frame = cw.ButtonRow(self.content_frame,
                                              frame_highlightthickness=0,
                                              background=light_color,
                                              frame_borderwidth=0)
        self.scanpathbox_frame.Put(
            relx=0.0,
            rely=0.0,
            height=searchboxheight,
            relwidth=1,
        )

        #frame to hold far right column
        self.rightcolumn = cw.ThemedFrame(self,
                                          frame_borderwidth=0,
                                          frame_highlightthickness=0,
                                          background=light_color)
        self.rightcolumn.place(relx=1,
                               x=-infoframewidth,
                               rely=0.0,
                               relheight=1,
                               width=infoframewidth)

        #generate table with column labels from list with column widths
        columns = [["FILE", None], ["TITLEID", 150], ["TYPE", 60],
                   ["SIZE", 100]]

        #Frame to hold primary lostbox
        self.list_frame = cw.ThemedFrame(self.content_frame,
                                         frame_highlightthickness=0,
                                         background=light_color)
        self.list_frame.place(relx=0,
                              rely=0,
                              y=searchboxheight,
                              relheight=1,
                              height=-(searchboxheight),
                              relwidth=1)

        #vertical scroll bar (Not placed, trying to make it only appear when needed)
        self.vsb = tk.Scrollbar(self.content_frame,
                                orient="vertical",
                                command=self.OnVsb)
        # self.vsb.place(relx=0.975, rely=0.15, relheight=0.94, relwidth=0.025)

        self.listbox_list = []
        popupcommands = [["Blacklist", self.blacklistTitle],
                         ["Remove", self.removeTitle]]
        self.maintable = cw.themedtable(self.list_frame,
                                        columns,
                                        popup_callback=self.refresh)
        self.maintable.place(relheight=1,
                             relwidth=1,
                             x=+separatorwidth,
                             height=-separatorwidth,
                             width=-separatorwidth)
        self.maintable.addpopupcommands(popupcommands)

        # bind listboxes to move with mouse scroll
        for column in columns:
            self.maintable.listboxes[column[0]].bind("<MouseWheel>",
                                                     self.OnMouseWheel)

        #set listboxes to easy names
        for listbox in self.maintable.listboxes:
            self.listbox_list.append(self.maintable.listboxes[listbox])

        self.filelistbox = self.maintable.listboxes["FILE"]
        self.titleidlistbox = self.maintable.listboxes["TITLEID"]
        self.typelistbox = self.maintable.listboxes["TYPE"]
        self.sizelistbox = self.maintable.listboxes["SIZE"]

        #Bind selecting an item to CurSelet
        self.filelistbox.bind('<<ListboxSelect>>', self.CurSelet)
        self.filelistbox.bind('<ButtonRelease-3>', self.on_right_click)

        for listbox in self.listbox_list:
            listbox.bind("<MouseWheel>", self.OnMouseWheel)

        self.infobox = infobox(self.rightcolumn)
        self.infobox.place(
            x=0,
            relwidth=1,
            y=0,
            relheight=1,
            height=-(stats_box_height + navbuttonheight + 2 * separatorwidth))

        self.left_context_button = cw.navbutton(self.rightcolumn,
                                                command_name=self.cursordown,
                                                text_string="PREV",
                                                background=dark_color)
        self.right_context_button = cw.navbutton(self.rightcolumn,
                                                 command_name=self.cursorup,
                                                 text_string="NEXT",
                                                 background=dark_color)
        self.left_context_button.place(relx=0,
                                       rely=1,
                                       y=-(navbuttonheight + separatorwidth),
                                       x=+separatorwidth,
                                       relwidth=0.5,
                                       width=-(2 * separatorwidth),
                                       height=navbuttonheight)
        self.right_context_button.place(relx=0.5,
                                        rely=1,
                                        y=-(navbuttonheight + separatorwidth),
                                        x=+0.5 * separatorwidth,
                                        relwidth=0.5,
                                        width=-(2 * separatorwidth),
                                        height=navbuttonheight)

        self.stats_box = statbox(self.rightcolumn)
        self.stats_box.place(
            x=0,
            rely=1,
            y=-(stats_box_height + navbuttonheight + separatorwidth),
            relwidth=1,
            height=stats_box_height + separatorwidth)

        self.speed = cw.ThemedLabel(self.stats_box, "n/a mbps")
        # self.speed.place(y=75, x=+separatorwidth, relwidth = 0.8, height = 15)

        self.text = cw.ThemedLabel(self.stats_box, "n/a")
        # self.text.place(y=90, x=+separatorwidth, relwidth = 0.8, height = 15)

        self.progbar = cw.progBar(self.stats_box)
        self.progbar.Place(y=60,
                           relx=0,
                           relwidth=1,
                           width=-2 * separatorwidth,
                           x=+separatorwidth,
                           height=15)
        self.progbar.hide()

        self.infoimage = tk.PhotoImage(
            file=os.path.join(self.cwd, "assets/info.png")).subsample(2)
        self.addimage = tk.PhotoImage(
            file=os.path.join(self.cwd, "assets/plus.png")).subsample(2)

        #Pil breaks this image
        self.scanimage = tk.PhotoImage(
            file=os.path.join(self.cwd, "assets/scan.png")).subsample(2)

        self.infoimage = ImageTk.PhotoImage(
            Image.open(os.path.join(self.cwd, "assets/info.png")).resize(
                (40, 40), Image.ANTIALIAS))
        self.addimage = ImageTk.PhotoImage(
            Image.open(os.path.join(self.cwd, "assets/plus.png")).resize(
                (25, 25), Image.ANTIALIAS))
        self.folderimage = ImageTk.PhotoImage(
            Image.open(os.path.join(self.cwd, "assets/folder.png")).resize(
                (25, 25), Image.ANTIALIAS))
        self.ximage = ImageTk.PhotoImage(
            Image.open(os.path.join(self.cwd,
                                    "assets/plus.png")).rotate(45).resize(
                                        (25, 25), Image.ANTIALIAS))
        #Set this to a list of buttons to appear next to the path bar
        buttonlist = [
            {
                "image": self.addimage,
                "callback": lambda: self.scanpathbox_frame.show(),
                "tooltip": "Scan a folder",
            },
            {
                "image": self.infoimage,
                "callback": lambda: self.controller.show_frame("helpFrame"),
                "tooltip": "Help",
            },
        ]

        scanbuttonlist = [
            {
                "image": self.ximage,
                "callback": lambda: self.scanpathbox_frame.hide(),
                "tooltip": "Back",
            },
            {
                "image": self.folderimage,
                "callback": self.selectRomsFolder,
                "tooltip": "Select Rom Folder",
            },
            {
                "image": self.scanimage,
                "callback": lambda: on_scan(self),
                "tooltip": "Scan Rom Folder",
            },
        ]

        self.searchbox_frame.setbuttons(
            buttonlist,
            set_pathbox=True,
            pathbox_placeholder="Search",
            pathbox_callback=self.updatetable,
            pathbox_callback_on_keystroke=True,
        )
        self.scanpathbox_frame.setbuttons(scanbuttonlist,
                                          set_pathbox=True,
                                          pathbox_placeholder="Path to scan")

        self.sp = self.scanpathbox_frame.sb
        self.sb = self.searchbox_frame.sb
        # self.searchbox_frame..set(str((os.path.abspath(Config.paths.scan))))

        self.showmainframe()
        self.refresh()
        self.klock()
        Users.export()
Example #6
0
    def __init__(self, parent, controller):
        self.controller = controller  #Controller (most toplevel parent)
        self.needsRefresh = True  #Variable to track if reload is needed

        width = infoframewidth + 10
        height = 95
        minwidth = infoframewidth + 10
        minheight = 95
        self.controller.geometry("{}x{}".format(width, height))
        self.controller.minsize(
            width=minwidth,
            height=minheight)  #minimum size currently supported
        self.controller.resizable(False, False)
        self.controller.title("MUNK")

        cw.ThemedFrame.__init__(self, parent)  #Init frame
        self.bind(
            "<<ShowFrame>>", self.on_show_frame
        )  #Bind on_show_frame to showframe event so whenever the frame is raised by the controller it reloads

        #Box to hold nut transfer info
        #-----------------------------------------------------------------------------------
        self.stats_box = statbox(self)
        self.stats_box.place(relwidth=1, relheight=1)

        self.speed = cw.ThemedLabel(self, "n/a mbps")
        # self.speed.place(y=75, x=+separatorwidth, relwidth = 0.8, height = 15)

        self.text = cw.ThemedLabel(self, "n/a")
        # self.text.place(y=90, x=+separatorwidth, relwidth = 0.8, height = 15)

        self.progbar = cw.ProgressBar(self)
        #self.progbar.special_place()
        # self.progbar.place(y = 115, x=+separatorwidth, relwidth = 0.8, height =15)
        #-----------------------------------------------------------------------------------
        self.scanpathbox_frame = cw.ButtonRow(self.stats_box)
        self.scanpathbox_frame.place(x=0, y=75, relwidth=1, height=20)

        #Images for buttons
        self.folderimage = ImageTk.PhotoImage(
            Image.open("assets/folder.png").resize((20, 20), Image.ANTIALIAS))
        self.scanimage = tk.PhotoImage(file="assets/scan.png").subsample(3)

        buttonlist = [
            {
                "image": self.scanimage,
                "callback": lambda: on_scan(self),
                "tooltip": "Scan Rom Folder",
            },
            {
                "image": self.folderimage,
                "callback": self.selectRomsFolder,
                "tooltip": "Select Rom Folder",
            },
        ]

        self.scanpathbox_frame.setbuttons(buttonlist,
                                          set_pathbox=True,
                                          pathbox_placeholder="Scan",
                                          frame_height=75,
                                          sep_width=separatorwidth / 2,
                                          background=light_color,
                                          font=smallertext)
        self.sp = self.scanpathbox_frame.sb

        Users.export()
Example #7
0
	def test_export(self):
		FILENAME = 'conf/users.conf'
		self.assertFalse(os.path.exists(FILENAME))
		Users.export()
		self.assertTrue(os.path.exists(FILENAME))