def download_flyvec_data(outfile=None, force=False):
    """Download the zipped flyvec model from the cloud to a local file. If `outfile` is not provided,
    use (the OS's) TEMPDIR / 'flyvec-data.zip'

    """
    tmp_file = Path(outfile) if outfile is not None else Path(
        tempfile.gettempdir()) / "flyvec-data.zip"
    if tmp_file.exists() and not force:
        print(f"Found existing {tmp_file}, reusing")
        return tmp_file

    access_key = "07598db5c9364ad29002fe8e22daddd3"
    secret_key = "a7bec64c8840439576380beb238b161117f2aeb3e7f993f0"
    service_endpoint = 'https://s3.ap.cloud-object-storage.appdomain.cloud'
    session = boto3.Session(aws_access_key_id=access_key,
                            aws_secret_access_key=secret_key,
                            region_name="ap-geo")

    s3 = session.resource("s3", endpoint_url=service_endpoint)
    bucket = s3.Bucket("hoo-flyvec")
    obj = bucket.Object("data.zip")
    down_progress = ProgressBar(obj.content_length)

    print("Downloading flyvec data:")
    down_progress.start()

    def download_progress(chunk):
        down_progress.update(down_progress.currval + chunk)

    with open(str(tmp_file), 'wb') as fd:
        obj.download_fileobj(fd, Callback=download_progress)

    down_progress.finish()

    return tmp_file
Esempio n. 2
0
 def pakt_init(
         name: typing.Optional[str],
         boot: bool = True) -> None:  # setting parameters and return types
     if not isinstance(
             name, str
     ):  # checking if the name provided is a string or not, type hinting doesn't raise errors iirc
         raise TypeError("`Name` has to be a string."
                         )  # raising error if they messed up
     # white space because clean code
     if not isinstance(boot, bool):  # checking if boot is a boolean or not
         raise TypeError("`Boot` has to be a boolean.")  # raising error
     # white space because clean code
     os.system("clear")  # clearing screen
     # more white space because clean code
     print("Initializing system")
     # more white space because clean code
     pakt_init_progress_bar = ProgressBar(
         maxval=100)  # creating instance of `ProgressBar`
     pakt_init_progress_bar.start()  # starting instance of `ProgressBar`
     # more white space because clean code
     for i in range(0, 100):  # creating loop to iterate over i
         if not isinstance(i, int):  # type checking
             raise TypeError(
                 "Iterator variable `i` must be an integer in this context."
             )  # raising error if type check fails
         # more white space because clean code
         pakt_init_progress_bar.update(i + 1)  # updating progress bar
         sleep(0.025)
         if random.randint(0, 100) < 75:  # generate random number
             sleep(2)  # do important init shit here
     pakt_init_progress_bar.finish(
     )  # finish progress bar (same with ur mother)
     # more white space because clean code
     print("Pakt Init is done initializing the system.")  # we are done
     ctypes.string_at(0)  # segfault python because F**K YOU
Esempio n. 3
0
def main():

    print "Loading configuration"
    with open("config.cfg", "r") as f:
        config = yaml.load(f)

    qa_contacts = config["qa_contacts"]
    flags = config["flags"]
    username = config.get("username", None)
    password = config.get("password", None)
    certificate_name = config["certificate_name"]

    username = os.getenv("BZ_USER", username)
    if not username:
        print(
            "Username was neither available at the config file or env vars (var name: BZ_USER)\n"
            "please input user name manually")
        username = raw_input("Username: "******"BZ_PASSWORD", password)
    if not password:
        print(
            "Password was neither available at the config file or env vars (BZ_USER)\n"
            "please input password manually")
        password = getpass.getpass()

    print "Collecting issues from Bugzilla"
    report_builder = report_gen("https://bugzilla.redhat.com",
                                username=username,
                                password=password)
    report_builder.parallelizer.start_parallelizer()

    for flag in flags:
        report_builder.get_issues_for_qa_contact(qa_contacts, flag)

    print ""
    print "*********************"
    print ""
    print "*** Total ***********"
    print "{count} issues found".format(count=len(report_builder.all_bugs))
    print "***By User **********"

    issues_by_user = {}

    for issue in report_builder.all_bugs:
        contact = issue[1]
        issues_by_user[contact] = issues_by_user.get(contact, 0) + 1

    for contact, count in issues_by_user.items():
        print "{contact}: {count}".format(contact=contact, count=count)
    print "*********************"
    print ""

    pbar = ProgressBar().start()
    pbar.start()

    while report_builder.parallelizer.has_tasks_on_pipeline:
        pbar.update(report_builder.parallelizer.get_done_percentage)
        time.sleep(0.2)
    pbar.finish()

    print "Waiting for all the workers to finish"
    report_builder.parallelizer.stop_parallelizer()

    print "Saving report to G cloud"
    report_builder.save_to_google_drive_full_report(qa_contacts, flags,
                                                    certificate_name)