Esempio n. 1
0
    def check_issue(self):
        self.debug('Check', 'Checking Issue.')

        db=sqlite3.connect(DB_FILE_NAME)
        cur = db.cursor()
    
        for key, value in GITHUB_SETTINGS.items():
            self.debug('Check', key + ': Checking.')
            c = client.Client(username=value['account'],
                            password=value['password'])

            for _key, _value in value['repos'].items():
                for _repo in _value:
                    repo = client.Repo(c, _key, _repo)
                    issues = repo.issues()

                    for issue in issues:
                        cur.execute("select issue_id from issue_id where\
                                    user = ? and\
                                    repo = ? and\
                                    issue_id = ?",\
                                    [_key,
                                    _repo,
                                    (str(issue['number']))])

                        if len(cur.fetchall()) == 0:
                            self.debug('Check',
                               '%s/%s: Find Issue #%d' % (_key,
                               _repo, issue['number']))

                            self.create_pdf(_key, _repo, issue)
                            self.print_pdf(_key, _repo, issue['number'])

                            db.execute('insert into issue_id(\
                                        user,\
                                        repo,\
                                        issue_id) values (?, ?, ?)',
                                        [_key,
                                        _repo,
                                        (str(issue['number']))])

                            db.commit()

        cur.close()
        db.close()
Esempio n. 2
0
    def init_db(self):
        self.debug('Init', 'Database Initializing.')

        if not (os.path.isfile(DB_FILE_NAME)):
            db=sqlite3.connect(DB_FILE_NAME)
            db.execute('create table issue_id(\
                        id integer PRIMARY KEY AUTOINCREMENT,\
                        user,\
                        repo,\
                        issue_id)')
        
            for key, value in GITHUB_SETTINGS.items():
                c = client.Client(username=value['account'],
                                password=value['password'])

                for _key, _value in value['repos'].items():
                    for _repo in _value:
                        repo = client.Repo(c, _key, _repo)
                        issues = repo.issues()

                        count = 0
                        for issue in issues:
                            db.execute('insert into issue_id(\
                                        user,\
                                        repo,\
                                        issue_id) values (?, ?, ?)',
                                        [_key,
                                        _repo,
                                        (str(issue['number']))])
                            count = count + 1

                        db.commit()
 
                        self.debug('Init',
                                   '%s/%s : Add %d issues.' % (_key,
                                   _repo, count))
        
            db.close()