Beispiel #1
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
Beispiel #2
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)