예제 #1
0
def progress_bar():
    denominator = 5 if OPTIONS['--fast'] else 100
    bar = ProgressBar(0 if OPTIONS['--undefined'] else denominator)
    for i in range(denominator + 1):
        bar.numerator = i
        print(bar, end='\r')
        sys.stdout.flush()
        time.sleep(0.25)
    bar.force_done = True  # Needed in case of --undefined.
    print(bar)  # Always print one last time.
예제 #2
0
def progress_bar():
    denominator = 5 if OPTIONS['--fast'] else 100
    bar = ProgressBar(0 if OPTIONS['--undefined'] else denominator)
    for i in range(denominator + 1):
        bar.numerator = i
        print(bar, end='\r')
        sys.stdout.flush()
        time.sleep(0.25)
    bar.force_done = True  # Needed in case of --undefined.
    print(bar)  # Always print one last time.
                (userdomainid, DisplayName, primary_smtp_address, domainserver, server) = _parse_response(response.text,
                                                                                                          'utf-8')

            except:
                (userdomainid, DisplayName, primary_smtp_address, domainserver, server) = None, None, None, None, None
            else:
                # print("DisplayName:%s,primary_smtp_address:%s,userdomainid:%s,domainserver:%s" % (
                # DisplayName, primary_smtp_address, userdomainid, domainserver))
                v = userdomainid, DisplayName, primary_smtp_address, domainserver, server
                if all(x is not None for x in v):
                    table.add_row([DisplayName, primary_smtp_address, userdomainid, domainserver])

                print(progress_bar, end='\r')
                sys.stdout.flush()
        progress_bar.numerator = nbr_mail
        progress_bar.force_done = True
        print(progress_bar)
        print(table)
    except requests.exceptions.ConnectionError as e:
        print(Color(u"{autored}[!]{/autored}Can not connect to the server at the given address"))
    except HTTPError as e:
        print('The server couldn\'t fulfill the request.')
        print('Error code: ', e.code)
    except URLError as e:
        print('We failed to reach a server.')
        print('Reason: ', e.reason)
    except HTTPException as e:
        print(Color(u"{autored}[!]{/autored}Can not connect to the server at the given address"))
        print('Reason: ', e.reason)
    except Exception as e:
        print(Color(u'{autored}[!]{/autored}An error has occurred %s ' % e ))