Exemplo n.º 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.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()
Exemplo n.º 2
0
	def test_load_with_empty_file(self):
		Users.users = {}
		Users.load()

		self.assertIsNotNone(Users.first())
		first_user = Users.first()
		self.assertEqual(first_user.id, _DEFAULT_USER)
		self.assertEqual(first_user.password, _DEFAULT_PASSWORD)
Exemplo n.º 3
0
def initThread(app):
    nut.scan()
    app.refresh()
    if Config.autolaunchBrowser:
        webbrowser.open_new_tab(
            'http://' + urllib.parse.quote_plus(Users.first().id) + ':' +
            urllib.parse.quote_plus(Users.first().password) + '@' +
            getIpAddress() + ':' + str(Config.server.port))
Exemplo n.º 4
0
    def tick(self):
        ip = getIpAddress()
        port = str(Config.server.port)
        user = Users.first().id
        passw = Users.first().password
        usbstat = str(Usb.status)

        self.updateIP(ip)
        self.updatePort(port)
        self.updateUser(user)
        self.updatePassword(passw)
        self.updateUSB(usbstat)
Exemplo n.º 5
0
	def test_auth_positive(self):
		auth_result = Users.auth(_DEFAULT_USER, _DEFAULT_PASSWORD, _DEFAULT_HOST)
		self.assertEqual(auth_result.id, _DEFAULT_USER)
		self.assertEqual(auth_result.password, _DEFAULT_PASSWORD)

		self.assertEqual(Users.first().remoteAddr, None)
		self.assertIsNotNone(Users.auth(_DEFAULT_USER, _DEFAULT_PASSWORD, 'any_adrr'))

		user = Users.first()
		user.setRequireAuth(False)
		user.remoteAddr = _DEFAULT_HOST
		Users.users[user.id] = user
		self.assertTrue(Users.auth(user.id, user.password, user.remoteAddr))

		user.setRequireAuth(True)
		self.assertTrue(Users.auth(_DEFAULT_USER, _DEFAULT_PASSWORD, user.remoteAddr))
		self.assertFalse(Users.auth(_DEFAULT_USER, _DEFAULT_PASSWORD, 'any_addr'))
Exemplo n.º 6
0
    def test_auth_positive(self):
        auth_result = Users.auth(_DEFAULT_USER, _DEFAULT_PASSWORD,
                                 _DEFAULT_HOST)
        self.assertEqual(auth_result.id, _DEFAULT_USER)
        self.assertEqual(auth_result.password, _DEFAULT_PASSWORD)

        self.assertEqual(Users.first().remoteAddr, None)
        self.assertIsNotNone(
            Users.auth(_DEFAULT_USER, _DEFAULT_PASSWORD, 'any_adrr'))
Exemplo n.º 7
0
Arquivo: server.py Projeto: 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()
Exemplo n.º 8
0
	def test_load(self):
		conf_file = 'conf/users.conf'
		conf_content = """id|password
user1|pwd1

user2|pwd2
# comment
user3|pwd3
"""
		self.fs.create_file(conf_file, contents=conf_content)

		Users.users = {}
		Users.load()

		self.assertIsNotNone(Users.first())
		first_user = Users.first()
		self.assertEqual(first_user.id, 'user1')
		self.assertEqual(first_user.password, 'pwd1')

		self.fs.remove(conf_file)
Exemplo n.º 9
0
	def test_user_serialize(self):
		user = Users.first()
		serialized = user.serialize()
		self.assertEqual(serialized, "guest|guest")
Exemplo n.º 10
0
	def test_first_user(self):
		first_user = Users.first()
		self.assertEqual(first_user.id, _DEFAULT_USER)
		self.assertEqual(first_user.password, _DEFAULT_PASSWORD)
		Users.users = {}
		self.assertIsNone(Users.first())