Example #1
0
    def runConfigWizard(self):
        try:
            api = InstagramAPI(
                client_id=self.options_string['hidden_client_id'],
                client_secret=self.options_string['hidden_client_secret'],
                redirect_uri=self.options_string['redirect_uri'])
            url = api.get_authorize_login_url()

            self.wizard.setWindowTitle('Instagram plugin configuration wizard')
            page1 = QWizardPage()
            layout1 = QVBoxLayout()
            txtArea = QLabel()
            txtArea.setText(
                'Please copy the following link to your browser window. \n ' +
                'Once you authenticate with Instagram you will be redirected to '
                +
                'www.geocreepy.com and get your token. Copy the token to the input field below:'
            )
            urlArea = QLineEdit()
            urlArea.setObjectName('urlArea')
            urlArea.setText(url)
            inputLink = QLineEdit()
            inputLink.setObjectName('inputLink')
            labelLink = QLabel('Your token value:')
            openInBrowserButton = QPushButton('Open in browser')
            openInBrowserButton.clicked.connect(
                functools.partial(self.openLinkInBrowser, url))
            layout1.addWidget(txtArea)
            layout1.addWidget(urlArea)
            layout1.addWidget(openInBrowserButton)
            layout1.addWidget(labelLink)
            layout1.addWidget(inputLink)
            page1.setLayout(layout1)
            self.wizard.addPage(page1)
            self.wizard.resize(600, 400)
            if self.wizard.exec_():
                c = str(inputLink.text())
                if c:
                    try:
                        access_token = api.exchange_code_for_access_token(
                            code=c)
                        self.options_string[
                            'hidden_access_token'] = access_token[0]
                        self.saveConfiguration(self.config)
                    except Exception, err:
                        logger.error(err)
                        self.showWarning(
                            'Error Getting Access Token',
                            'Please verify that the link you pasted was correct. '
                            'Try running the wizard again.')
                else:
                    self.showWarning(
                        'Error Getting Access Token',
                        'Please verify that the link you pasted was correct. Try running the wizard again.'
                    )

        except Exception, err:
            logger.error(err)
            self.showWarning('Error', 'Error was {0}'.format(err))
Example #2
0
    def runConfigWizard(self):
        try:
            oAuthHandler = tweepy.OAuthHandler(self.options_string['hidden_application_key'],
                                               self.options_string['hidden_application_secret'])
            authorizationURL = oAuthHandler.get_authorization_url(True)

            self.wizard.setWindowTitle('Twitter plugin configuration wizard')
            page1 = QWizardPage()
            page2 = QWizardPage()
            layout1 = QVBoxLayout()
            layout2 = QVBoxLayout()
            layoutInputPin = QHBoxLayout()

            label1a = QLabel(
                'Click next to connect to twitter.com . Please login with your account and follow the instructions in '
                'order to authorize creepy')
            label2a = QLabel(
                'Copy the PIN that you will receive once you authorize cree.py in the field below and click finish')
            pinLabel = QLabel('PIN')
            inputPin = QLineEdit()
            inputPin.setObjectName('inputPin')

            analysisHtml = QWebView()
            analysisHtml.load(QUrl(authorizationURL))

            layout1.addWidget(label1a)
            layout2.addWidget(analysisHtml)
            layout2.addWidget(label2a)
            layoutInputPin.addWidget(pinLabel)
            layoutInputPin.addWidget(inputPin)
            layout2.addLayout(layoutInputPin)

            page1.setLayout(layout1)
            page2.setLayout(layout2)
            page2.registerField('inputPin*', inputPin)
            self.wizard.addPage(page1)
            self.wizard.addPage(page2)
            self.wizard.resize(800, 600)

            if self.wizard.exec_():
                try:
                    oAuthHandler.get_access_token(str(self.wizard.field('inputPin').toString()).strip())
                    self.options_string['hidden_access_token'] = oAuthHandler.access_token
                    self.options_string['hidden_access_token_secret'] = oAuthHandler.access_token_secret
                    self.saveConfiguration(self.config)
                except Exception, err:
                    logger.error(err)
                    self.showWarning('Error completing the wizard',
                                     'We were unable to obtain the access token for your account, please try to run '
                                     'the wizard again. Error was {0}'.format(err.message))

        except Exception, err:
            logger.error(err)
            self.showWarning('Error completing the wizard', 'Error was: {0}'.format(err.message))
Example #3
0
    def introPage(self):
        intro = QWizardPage()

        intro.setTitle('Hello and welcome')
        label = QLabel('''This is a wizard.
Now you're ready to forecast some time series!
        ''')

        label.setWordWrap(True)
        layout = QVBoxLayout()
        layout.addWidget(label)
        intro.setLayout(layout)

        return intro
Example #4
0
    def runConfigWizard(self):
        try:
            api = InstagramAPI(client_id=self.options_string['hidden_client_id'],
                               client_secret=self.options_string['hidden_client_secret'],
                               redirect_uri=self.options_string['redirect_uri'])
            url = api.get_authorize_login_url()

            self.wizard.setWindowTitle('Instagram plugin configuration wizard')
            page1 = QWizardPage()
            layout1 = QVBoxLayout()
            txtArea = QLabel()
            txtArea.setText('Please copy the following link to your browser window. \n ' +
                            'Once you authenticate with Instagram you will be redirected to ' +
                            'www.geocreepy.com and get your token. Copy the token to the input field below:')
            urlArea = QLineEdit()
            urlArea.setObjectName('urlArea')
            urlArea.setText(url)
            inputLink = QLineEdit()
            inputLink.setObjectName('inputLink')
            labelLink = QLabel('Your token value:')
            openInBrowserButton = QPushButton('Open in browser')
            openInBrowserButton.clicked.connect(functools.partial(self.openLinkInBrowser, url))
            layout1.addWidget(txtArea)
            layout1.addWidget(urlArea)
            layout1.addWidget(openInBrowserButton)
            layout1.addWidget(labelLink)
            layout1.addWidget(inputLink)
            page1.setLayout(layout1)
            self.wizard.addPage(page1)
            self.wizard.resize(600, 400)
            if self.wizard.exec_():
                c = str(inputLink.text())
                if c:
                    try:
                        access_token = api.exchange_code_for_access_token(code=c)
                        self.options_string['hidden_access_token'] = access_token[0]
                        self.saveConfiguration(self.config)
                    except Exception, err:
                        logger.error(err)
                        self.showWarning('Error Getting Access Token',
                                         'Please verify that the link you pasted was correct. '
                                         'Try running the wizard again.')
                else:
                    self.showWarning('Error Getting Access Token',
                                     'Please verify that the link you pasted was correct. Try running the wizard again.')

        except Exception, err:
            logger.error(err)
            self.showWarning('Error', 'Error was {0}'.format(err))
Example #5
0
 def _create_page_id_files(self):
     """Creates a page for selecting student id files."""
     page = QWizardPage(self)
     page.setTitle(_('Student id files'))
     page.setSubTitle(_('You can select zero, one or more files with the '
                        'list of student ids. Go to the user manual '
                        'if you don\'t know the format of the files.'))
     self.files_w = widgets.MultipleFilesWidget(
                           _('Select student list files'),
                           file_name_filter=FileNameFilters.student_list,
                           check_file_function=self._check_student_ids_file)
     layout = QVBoxLayout()
     page.setLayout(layout)
     layout.addWidget(self.files_w)
     return page
Example #6
0
 def _create_page_id_files(self):
     """Creates a page for selecting student id files."""
     page = QWizardPage(self)
     page.setTitle(_('Student id files'))
     page.setSubTitle(_('You can select zero, one or more files with the '
                        'list of student ids. Go to the user manual '
                        'if you don\'t know the format of the files.'))
     self.files_w = widgets.MultipleFilesWidget(
                           _('Select student list files'),
                           file_name_filter=FileNameFilters.student_list,
                           check_file_function=self._check_student_ids_file)
     layout = QVBoxLayout()
     page.setLayout(layout)
     layout.addWidget(self.files_w)
     return page
Example #7
0
    def resultsPage(self):
        results = QWizardPage()
        results.setFinalPage(True)
        results.setTitle('Results')

        self.graph = QLabel("<font style='font-size: 16px;'>Plot</font>")
        self.export = QLabel("<font style='font-size: 16px;'>Export</font>")
        self.showData = QLabel("<font style='font-size: 16px;'>Data</font>")
        
        self.plotResult = MplWidget(None)
        self.plotResult.canvas.fig.set_facecolor('white')
        self.resData = QLabel('')
        self.resData.setAlignment(Qt.AlignCenter)
        self.resData.setWordWrap(True)
        self.resData.hide()

        self.resFilter = ResFilter()

        self.resLayout = QVBoxLayout()
        self.resLayout.addWidget(self.export)
        self.resLayout.addWidget(self.graph)
        self.resLayout.addWidget(self.showData)
        self.resLayout.addWidget(self.plotResult)
        self.resLayout.addWidget(self.resData)

        self.plotResult.hide()

        for index in range(0, self.resLayout.count()):
            try:
                self.resLayout.itemAt(index).widget().setAlignment(Qt.AlignCenter)
                self.resLayout.itemAt(index).widget().setStyleSheet('QLabel { color: gray; }')
                self.resLayout.itemAt(index).widget().setAttribute(Qt.WA_Hover)
                self.resLayout.itemAt(index).widget().installEventFilter(self.resFilter)
            except Exception:
                pass

        self.resLayout.setAlignment(Qt.AlignCenter)
        self.resLayout.setSpacing(60)

        results.setLayout(self.resLayout)

        return results
Example #8
0
    def runConfigWizard(self):
        try:
            oAuthHandler = tweepy.OAuthHandler(
                self.options_string['hidden_application_key'],
                self.options_string['hidden_application_secret'])
            authorizationURL = oAuthHandler.get_authorization_url(True)

            self.wizard.setWindowTitle("Twitter plugin configuration wizard")
            page1 = QWizardPage()
            page2 = QWizardPage()
            layout1 = QVBoxLayout()
            layout2 = QVBoxLayout()
            layoutInputPin = QHBoxLayout()

            label1a = QLabel(
                "Click next to connect to twitter.com . Please login with your account and follow the instructions in order to authorize creepy"
            )
            label2a = QLabel(
                "Copy the PIN that you will receive once you authorize cree.py in the field below and click finish"
            )
            pinLabel = QLabel("PIN")
            inputPin = QLineEdit()
            inputPin.setObjectName("inputPin")

            html = QWebView()
            html.load(QUrl(authorizationURL))

            layout1.addWidget(label1a)
            layout2.addWidget(html)
            layout2.addWidget(label2a)
            layoutInputPin.addWidget(pinLabel)
            layoutInputPin.addWidget(inputPin)
            layout2.addLayout(layoutInputPin)

            page1.setLayout(layout1)
            page2.setLayout(layout2)
            page2.registerField("inputPin*", inputPin)
            self.wizard.addPage(page1)
            self.wizard.addPage(page2)
            self.wizard.resize(800, 600)

            if self.wizard.exec_():
                try:
                    oAuthHandler.get_access_token(
                        str(self.wizard.field("inputPin").toString()).strip())
                    self.options_string[
                        'hidden_access_token'] = oAuthHandler.access_token
                    self.options_string[
                        'hidden_access_token_secret'] = oAuthHandler.access_token_secret
                    self.config.write()
                except Exception, err:
                    logger.error(err)
                    self.showWarning(
                        "Error completing the wizard",
                        "We were unable to obtain the access token for your account, please try to run the wizard again. Error was {0}"
                        .format(err.message))

        except Exception, err:
            logger.error(err)
            self.showWarning('Error completing the wizard',
                             'Error was: {0}'.format(err.message))