Beispiel #1
0
def run(quit_callback=None):
    if license.get_license():
        rumps.notification("HappyMac",
                           "HappyMac is now running",
                           "See the emoji icon in the status bar",
                           sound=False)
        HappyMacStatusBarApp(quit_callback).run()
Beispiel #2
0
def get_info(message):
    # Message contains repo, owner, token keys
    repo_info = get_repo_info(message["owner"], message["repo"])
    return_message = {
        "contact": get_contact(message["owner"], repo_info),
        "license": get_license(message["owner"], repo_info),
        "doi": get_doi('https://github.com/%s/%s' % (message["owner"],
                       message["repo"]), message["token"])
    }
    emit('info', return_message)
Beispiel #3
0
def get_info(message):
    # Message contains repo, owner keys
    owner_name = message["owner"].lower()
    current_owner = db.session.query(Owner).filter_by(name=owner_name).first()
    repo_name = message["repo"].lower()

    if 'refresh' not in message:
        if current_owner:
            current_repo = db.session \
                             .query(Repo)\
                             .filter_by(name=repo_name,
                                        owner_id=current_owner.id).first()
            if current_repo:
                return_message = {
                    "contact": current_repo.contact_info,
                    "license": [current_repo.license,
                                current_repo.license_url],
                    "doi": [current_repo.doi, current_repo.doi_url],
                    "documentation": current_repo.documentation
                }
                emit('info', return_message)
                return

    readme = get_readme(message["owner"], message["repo"])
    repo_info = get_repo_info(message["owner"], message["repo"])
    return_message = {
        "contact": get_contact(message["owner"], message["repo"], repo_info,
                               readme),
        "license": get_license(message["owner"], repo_info),
        "doi": get_doi('https://github.com/%s/%s' % (message["owner"],
                       message["repo"])),
        "documentation": has_docs(message["owner"], message["repo"], readme)
    }

    if current_owner:
        old_repo = Repo.query.filter((Repo.name == repo_name) |
                                     (Repo.owner_id ==
                                      current_owner.id)).first()
        if old_repo:
            db.session.delete(old_repo)

    if not current_owner:
        current_owner = Owner(owner_name)
        db.session.add(current_owner)

    current_repo = Repo(current_owner, repo_name,
                        return_message["documentation"],
                        return_message["doi"][0], return_message["doi"][0],
                        return_message["contact"],
                        return_message["license"][0],
                        return_message["license"][1])
    db.session.add(current_repo)
    db.session.commit()
    emit('info', return_message)
Beispiel #4
0
 def activate_tg(self):
     self.b.get(self.url_login)
     time.sleep(1)
     if self.b.title != u'login':
         WebDriverWait(self.b, 5, 0.5).until(
             lambda b: b.find_element_by_id("licenseState").is_displayed())
         self.b.find_element_by_id('machineCode').click()
         device_code = self.b.find_element_by_class_name(
             'layui-layer-content').text
         license = get_license(device_code)
         self.b.find_element_by_class_name('layui-layer-btn0').click()
         self.b.find_element_by_id('licenseCode').send_keys(license)
         self.b.find_element_by_id('licenseClick').click()
         WebDriverWait(self.b, 5,
                       0.5).until(lambda b: b.find_element_by_class_name(
                           "layui-layer-title").is_displayed())
         self.b.find_element_by_class_name('layui-layer-btn0').click()
Beispiel #5
0
 def test_get_license(self, mock_get):
     mock_get.return_value = None
     self.assertEqual(
         license.get_license(),
         u'0e69a4f4-ae73-47f8-8d87-7205b4b96e15'
     )