示例#1
0
 def __init__(self, args):
     super(MainApp, self).__init__(args)
     self.cookies = None
     mainPath = os.path.join( os.path.dirname(
         os.path.abspath(__file__) ), 'fonts' )
     for fontFile in glob.glob( os.path.join( mainPath ,
                                              '*.ttf' ) ):
         QFontDatabase.addApplicationFont( fontFile )
     #
     ##
     self.aw = ArticleWidget( self )
     self.alw = ArticlesListWidget( self )
     self.lw = LoginWindow( self )
     self.aw.hide()
     self.alw.hide()
     self.lw.hide()
     self.aboutToQuit.connect( self.cleanUp )
class LoginController(ProcessWithThreadsMixin):
    def __init__(self, app):
        super().__init__()
        self.app = app
        self.view = LoginWindow(self)
        self.jira_client = None
        self.set_loading_indicator()

    def show(self):
        self.view.show()

    def login(self):
        self.start_loading(self.connect_to_jira, self.open_main_window)

    def connect_to_jira(self):
        email = self.view.email_field.text()
        token = self.view.token_field.text()
        try:
            self.jira_client = JiraClient(email, token)
            self.jira_client.client.search_issues(
                'assignee = currentUser()',
                maxResults=1)  # check if username is correct
            # use search_issues because jira.current_user always return none
            if self.view.remember_me_btn.isChecked():
                self.remember_me(email, token)
        except JIRAError:
            raise ValueError('Email or token is incorrect')
        except UnicodeEncodeError:
            raise ValueError('English letters only')

    def remember_me(self, email, token):
        """
        Save email and token into my_credentials.txt
        with 600 permission
        """

        with open(CREDENTIALS_PATH, 'w', encoding='utf-8') as file:
            file.write('{email};{token}'.format(email=email, token=token))

        os.chmod(CREDENTIALS_PATH, stat.S_IRUSR | stat.S_IWUSR)

    def open_main_window(self, error_text):
        if error_text:
            self.view.set_error_to_label(error_text)
        else:
            main_controller = MainController(self.jira_client)
            main_controller.show()
            self.app.setQuitOnLastWindowClosed(False)
            self.view.close()
示例#3
0
from login_window import LoginWindow

# def window():
#     app = QApplication(sys.argv)
#     win = QMainWindow()
#     win.setGeometry(1000, 200, 300, 300)  # (x,y,w,h) --> where start(x,y) how big(w,h)
#     win.setWindowTitle("Polito Sync Material")
#
#     label = QtWidgets.QLabel(win)
#     label.setText("label")
#     label.move(50, 50)
#
#     win.show()
#     sys.exit(app.exec_())
#
if __name__ == "__main__":
    session = PolitoWebClass()
    try:
        with open("settings.json") as s:
            settings = json.load(s)
    except:
        print("Error: rename settings file as settings.json")

    session.set_download_folder(settings['download_folder'])
    session.set_file_name('web')
    app = QtWidgets.QApplication(sys.argv)
    window = LoginWindow(session)
    window.show()

    sys.exit(app.exec_())
示例#4
0
    user = controller.find(username)
    if user:
        user.name = input('Ingrese el nuevo nombre: ')
        user.role = input('Ingrese el nuevo rol: ')
        user.password = password_input(controller)
        controller.update(user)
    else:
        print('Error: El usuario que intenta editar no existe')


def delete(controller):
    username = input('Ingrese el usuario a eliminar: ')
    user = controller.find(username)
    if user:
        controller.delete(user)
    else:
        print('Error: El usuario que intenta eliminar no existe')


def password_input(controller):
    password = input('Ingrese la contraseña: ')
    while True:
        if len(password) == 4 and password.isdigit():
            return controller.encrypt_password(password)
        password = input('Ingrese una contraseña válida: ')


if __name__ == '__main__':
    # menu()
    LoginWindow().main()
 def __init__(self, app):
     super().__init__()
     self.app = app
     self.view = LoginWindow(self)
     self.jira_client = None
     self.set_loading_indicator()
示例#6
0
    # Program state
    state = State()

    # Tray Icon
    tray_icon = SystemTrayIcon(state)
    tray_icon.show()

    # Start device thread
    device_thread = QThread()
    device = connect.Device()
    device.moveToThread(device_thread)
    device_thread.started.connect(device.run)

    # Login Window
    login = LoginWindow(state, device)

    # Calibration Window
    calib_window = CalibrationWindow(state, device)

    # Popup Window
    popup = PopupWindow(state, device)

    def show_popup():
        if state.sensor_values is None:
            calib_window.start()
        else:
            popup.start()

    login.loginSuccess.connect(show_popup)
    calib_window.calibrated.connect(show_popup)
示例#7
0
from PyQt5.QtWidgets import QApplication
import sys
from login_window import LoginWindow

# Starting the application
app = QApplication(sys.argv)
mainwindow = LoginWindow()

# Exiting
try:
    sys.exit(app.exec_())
except:
    print("Exiting")
示例#8
0
class MainApp(QApplication):
    def __init__(self, args):
        super(MainApp, self).__init__(args)
        self.cookies = None
        mainPath = os.path.join( os.path.dirname(
            os.path.abspath(__file__) ), 'fonts' )
        for fontFile in glob.glob( os.path.join( mainPath ,
                                                 '*.ttf' ) ):
            QFontDatabase.addApplicationFont( fontFile )
        #
        ##
        self.aw = ArticleWidget( self )
        self.alw = ArticlesListWidget( self )
        self.lw = LoginWindow( self )
        self.aw.hide()
        self.alw.hide()
        self.lw.hide()
        self.aboutToQuit.connect( self.cleanUp )

    def doLogon(self):
        time0 = time.time()
        print 'STARTING TO LOGIN'
        statusdict = get_database_data( )
        print 'FINISHED LOGIN STUFF IN %0.3f SECONDS: %s' % (
            time.time() - time0, statusdict['message'] )
        if statusdict['message'] != 'SUCCESS':
            self.lw.setFromStatus( statusdict )
            self.lw.show()
        else:
            self.cookies = statusdict['cookies']
            email = statusdict['email']
            password = statusdict['password']
            data = get_article_data( email, password, self.cookies )
            self.pushData( data['articles'], data['ids_ordered'] )
            
    def pushDataFromCreds(self, email, password, cookies ):
        self.cookies = cookies
        data = get_article_data( email, password, cookies )
        self.pushData( data['articles'], data['ids_ordered'] )        
            
    def pushData(self, articles, ordered_ids ):
        self.articles = copy.deepcopy( articles )
        self.alw.pushTableData( articles, ordered_ids )
        self.lw.hide()
        self.lw.wipeAllData()
        self.alw.show()
        self.aw.show()

    def cleanUp(self):
        url = urljoin( 'https://tanimislam.ddns.net',
                       '/flask/api/nprstuff/readability/logout' )
        resp = requests.get( url, cookies = self.cookies )        

    def pushContent(self, articleId ):
        assert(articleId in self.articles )
        self.aw.articlePanel.setHtml( BeautifulSoup(
            self.articles[ articleId ]['content'], 'lxml' ).prettify() )
        self.aw.titleLabel.setText(
            titlecase.titlecase( self.articles[ articleId ]['title' ] ) )
        s_dt = self.articles[ articleId ]['date_published' ]
        wc = self.articles[ articleId ]['word_count']
        if s_dt is None:
            dtime = _badDate
            date_string = 'NODATE'
            time_string = 'NOTIME'
        else:
            dtime = datetime.datetime.strptime( s_dt, '%Y-%m-%d %H:%M:%S' )
            date_string = dtime.strftime('%m/%d/%Y')
            time_string = dtime.strftime('%H:%M:%S')
        self.aw.dateLabel.setText( date_string )
        self.aw.timeLabel.setText( time_string )
        self.aw.wcLabel.setText( '%d words' % wc )