Exemplo n.º 1
0
def debug_mode(user_links):
    global info
    info = WorkInformation('debug')
    for i in range(len(user_links)):
        user_links[i] = urlparse(user_links[i]).path[1:]
    user_links = str(user_links).replace(' ', '')
    user_links = user_links[2:len(user_links) - 2]
    users = info.api.users.get(user_ids=user_links,
                               fields='screen_name',
                               v=info.V)
    for user in users:
        like(user[u'id'], user, info.likes_amount)
Exemplo n.º 2
0
def update_variables():
    try:
        WorkInformation('initial')
        print('Configures currently saved. You can now run without argument')
    except KeyboardInterrupt:
        print('\nProcess of configure interrupted by user')
Exemplo n.º 3
0
def update_token():
    try:
        WorkInformation('update token')
        print('Re-auth finished successfully')
    except KeyboardInterrupt:
        print('\nAuth interrupted by user')
Exemplo n.º 4
0
    users = info.api.users.get(user_ids=user_links,
                               fields='screen_name',
                               v=info.V)
    for user in users:
        like(user[u'id'], user, info.likes_amount)


if __name__ == '__main__':
    try:
        if len(sys.argv) == 2 and sys.argv[1] == 'init':
            update_variables()
        elif len(sys.argv) == 2 and sys.argv[1] == 'update_token':
            update_token()
        elif len(sys.argv) > 2 and sys.argv[1] == 'debug':
            debug_mode(sys.argv[2:])
        elif len(sys.argv) == 1:
            info = WorkInformation('worker')
            work()
        else:
            print('Invalid argument usage')
    except ReadTimeout:
        print('Timeout (connection broken)')
        if info is not None:
            info.write_vars()
    except ConnectionError:
        print('Connection not established')
    except KeyboardInterrupt:
        if info is not None:
            info.write_vars()
        print('\nProcess interrupted, current state saved')