Beispiel #1
0
def run(histries, filename, desc, execute=False, noop=True, private=False):
    """Build contents and post it to gist."""
    commands = []

    for cmd in histries:
        output = util.capture_output(cmd)['output'] if execute else ''
        commands.append({
                'command': cmd,
                'output': output,
                })

    body = util.build_body(commands)

    if noop:
        print body
        return

    gist = Gist()
    if not gist.check_token():
        (username, password) = util.prompt_username_and_password(
            'Token not found so attempt to create.')
        gist.authorize(username, password)

    res = gist.create(filename, desc, body, public=not private)

    if res:
        print 'created on %s' % res['html_url']
    else:
        sys.stderr.write('failed to create\n')
Beispiel #2
0
def main():
    username = input('Введите логин вк: ')
    # username = "******"
    # username = "******"
    # username = "******"

    client_get_id = ClientGetID(username)
    user_id = client_get_id.execute()

    if client_get_id.is_success():
        print("ID: ", user_id)
    else:
        print('Нету такого айди, мэн')
        return

    # find age list
    friends_ages_list = ClientGetFriendsAges(user_id).execute()
    if not friends_ages_list:
        print('УУУУУ, нет друзей')
        return
    else:
        print("Ages: ", friends_ages_list)
        # write gist
        username_friend_gist = Gist(friends_ages_list)
        username_friend_gist.printGist()

    # show gist
    title = "Ages of Users "
    title_x = "Ages"
    title_y = "Users"
    username_friend_gist.showBar(title, title_x, title_y)
Beispiel #3
0
    def upload_gist(self, commands):
        username = self.conf['github'].get('username')
        api_key = self.conf['github'].get('api_key')
        public = self.conf['github'].get('public', True)

        gist = Gist(username = username, api_key = api_key, public = public)
        gist.description = self.title

        for filename in self.files:
            path = os.path.join(self.bugdir, filename)
            with open(path) as f:
                content = f.read()

            gist.add_file(filename, content)

        for (filename, content) in commands.items():
            gist.add_file(filename, content)

        return gist.create()
Beispiel #4
0
                ],
                'point_packages':
                sorted(self.packages, key=lambda pak: pak['pack_name']),
                '@metadata': {
                    'version': 1.4,
                    'compatible_since': 1.4,
                    'timestamp': time.time(),
                    'runtime': time.time() - self.start
                }
            },
            indent=4,
            sort_keys=True)


if __name__ == "__main__":
    _b = Builder()
    _b.parse_packages()
    _b.run()
    filepath = os.path.abspath(
        os.path.dirname(os.path.realpath(__file__)) +
        '/../data/store_items.json')
    print(filepath, flush=True)
    os.makedirs(os.path.dirname(filepath), exist_ok=True)
    _b.write(filepath)
    _g = Gist(gist_id='9b64e0f0452001883cb341fee975c12b',
              bkup_file='../api_key.key')
    if _g.change('data.json', _b.to_string()):
        print('Done. Pushed changes.')
    else:
        print('Done.')