Exemplo n.º 1
0
def GenerateRandomPassword():
    clearscreen()
    random_password = RandomPassword()
    random_password_green = ConsoleColored(random_password, "green", 1)
    print(f"your random password: {random_password_green}")

    pyperclip.copy(random_password)
    print("was copied to clipboard")

    windows_notification(
        "PasswordManager",
        random_password,
        2,
        "icons\\exec.ico",
    )

    current_datetime = GetCurrentDatetime(datetime_format)
    with open(f"logs\\password_generator\\log_{current_datetime}.txt",
              "w+",
              encoding="utf-8") as file:
        date, time = current_datetime.split("_")
        file.write(
            f"random password {random_password} was generated at\ndate: {date} \ntime: {time}."
        )

    pauseprogram()
Exemplo n.º 2
0
def notification():
    windows_notification(
        "ImageToPNG",
        "converted successfully!\nplaced in original folder",
        5,
        "icons/suc.ico",
        1
    )
Exemplo n.º 3
0
def PasswordGenerator():
    random_password = RandomPassword()
    pyperclip.copy(random_password)
    password_colored = ConsoleColored(random_password, "green", bold=1)
    print(
        f"\nPassword [ {password_colored} ] was copied to clipboard successfully!\n"
    )

    windows_notification("PasswordGenerator", random_password, 10,
                         "icons\\1.ico", True)
Exemplo n.º 4
0
def ImageToICO():
    while 1:
        clearscreen()
        IntroductionMessage("ImageToICO")

        image_path = input("[enter the path of your image] OR [DRAG AND DROP the image]:\n{} ".format(left_arrow_3_green_bold))

        # is not a file
        if not is_file(image_path):
            continue

        # being an ico is not valid
        ext = get_file_extension(image_path).lower()
        if ext == "ico":
            continue

        # is not an image
        if ext.lower() not in "jpg_jpeg_png":
            continue


        print("\nImage from path: {}".format(yellow_bold(image_path)))
        destination_folder = ConvertImage(image_path)

        os.system(f"nautilus {destination_folder} &")
        print_green_bold("folder opened!")

        # windows success notification
        if linux:
            linux_notification(
                "ImageToICO",
                "converted successfully!",
                "icons/1.ico"
            )
        else:
            windows_notification(
                "ImageToICO",
                "converted successfully!\n\nplaced in original folder",
                2,
                "icons/1.ico",
                1
            )

        print()
        pauseprogram()
Exemplo n.º 5
0
    def LikeAllNearbyGirls(self, iterations=1):
        """
            aparent pot sa dau like cat vreau
            chiar daca pe tinder.com nu mai am likeuri
            aici pot sa vad useri si sa le dau like la infinit
            asta practic sfideaza legile tinderului which is cool

            this function is listing nearby girls, likes them',
            tells me if i have a match with them and appends the users
            into the TinderUsers list
        """
        tinder_users_list = GetTinderUsersList()

        for user in itertools.islice(self.tinder_session.yield_users(), iterations):
            print("~" * 70)
            user_metadata = {
                "name": user.name,
                "id": user.id,
                "age": user.age,
                "bio": user.bio,
                "gender": user.gender,
                "photos_url_list": user.photos,
                "liked": True
            }
            matched = user.like()

            if matched:
                user_metadata["matched"] = True
                print(ConsoleColored("MATCHED!!!", "green", bold=1))
                windows_notification("Tinder MATCH", "you got a match with {}".format(user.name), 2, "icons/tinder_logo.ico")
            else:
                user_metadata["macthed"] = False
                print(ConsoleColored("no match.", "red", bold=1))

            print(json.dumps(user_metadata, indent=8))
            print("{} liked successfully!".format(user.name))

            UpdateTinderUsersList(tinder_users_list, user_metadata)
            OverwriteTinderUsersList(tinder_users_list)

            print("{} added to database successfully!".format(user.name))
            print("~" * 70)
            print("=" * 80)
Exemplo n.º 6
0
    "git push -f origin master"
]

colored_commands = [
    f"{red_bold('rmdir')} /S /Q {cyan(project_folder + sep + '.git')}",
    f"{yellow_bold('git')} init", f"{yellow_bold('git')} add .",
    f"{yellow_bold('git')} commit - m \"{green(commit_message)}\"",
    f"{yellow_bold('git')} remote add origin {orange_underlined(repo_git_url)}",
    f"{yellow_bold('git')} push -f origin master"
]

print("The following commands will be executed:")
for c in colored_commands:
    print("\t" + c)

choice = input("\nproceed? [y/n]:\n>>> ")
if choice == "y":
    os.chdir(project_folder)

    print()
    for command, command_colored in zip(commands, colored_commands):
        print(command_colored)
        os.system(command)

    print_green("\nrepo {} was updated successfully!\n".format(
        cyan_underlined(repo_url)))

    webbrowser.open(repo_url)

    windows_notification("Github", "Repo: alexzander/python372\nUPDATED", 5,
                         "python_logo.ico", 1)
Exemplo n.º 7
0
    def backup_to_server(self, less_24_mode=True, zip_mode=True):
        if not self.is_server_online():
            self.logger_backup.info(
                f"warning: server {self.server_http_url} is OFFLINE")

        backup_start_time = time()
        backup_start_datetime = get_current_datetime()

        if zip_mode:
            # files generation
            self.logger_backup.info("generating files ...")
            files_collection = ExtractFiles(*GetMainContents(),
                                            less_24_mode=less_24_mode,
                                            verbose=1,
                                            overwrite=self.overwrite)
            self.logger_backup.info("generated.")

            if less_24_mode:
                _name = "less_24_files"
            else:
                _name = "all_files"

            # Path object
            tar_gz_file = CompressFiles(files_collection,
                                        _name,
                                        overwrite=self.overwrite)
            del _name

            if not self.is_server_online():
                if windows:
                    windows_notification(
                        "Backup Client",
                        "start python webserver for backup! (2 mins left until start)",
                        5, "assets/icons/backup.ico", 1)
                self.logger_backup.info(
                    f"server: {self.server_http_url} is OFFLINE (this time sleeping 2 minutes)"
                )
                sleep(2 * 60)

            # last chance
            if not self.is_server_online():
                self.logger_backup.exception(
                    f"server: {self.server_http_url} is OFFLINE")
                raise ConnectionError(
                    f"server: {self.server_http_url} is OFFLINE")

            self.logger_backup.info(
                f"\nBackup to: {self.server_http_url} started at: {backup_start_datetime}\n"
            )

            subprocess.call(
                self.pscp_command.safe_substitute(
                    file_path=tar_gz_file.absolute().as_posix(),
                    destination_folder=server_backup_folder))

            tar_gz_file.unlink()

            response = requests.post(self.server_http_url,
                                     json={
                                         "extract":
                                         1,
                                         "zip_path":
                                         server_backup_folder +
                                         tar_gz_file.name
                                     })
            if response.status_code != 200:
                try:
                    response.raise_for_status()
                except requests.RequestException:
                    self.logger_backup.exception(
                        f"Status code: {response.status_code}\n")
                    response.raise_for_status()

            if not response.json()["extract_result"] == "success":
                raise ValueError(response.json()["extract_result"])

            backup_finish_datetime = get_current_datetime()
            self.logger_backup.info(
                f"tar.gz extracted on server successfully\nBackup to: {self.server_http_url} ended at: {backup_finish_datetime}"
            )

            # tar_gz_file.unlink(missing_ok=False)
            self.logger_backup.info(f"{tar_gz_file.name} deleted")

        else:
            # NON ZIP MODE

            # files generation
            self.logger_backup.info("generating files ...")
            files_collection = ExtractFiles(*GetMainContents(),
                                            less_24_mode=less_24_mode,
                                            verbose=1,
                                            overwrite=1)
            self.logger_backup.info("generated.")
            if less_24_mode:
                _name = "less_24_files"
            else:
                _name = "all_files"

            self.logger_backup.info(
                "generating array with BackupApplicationFiles files ...")
            files_collection = InstantiateWithBackupApplicationFile(
                files_collection, server_backup_folder, _name)
            del _name
            self.logger_backup.info("generated.")

            if not self.is_server_online():
                if windows:
                    windows_notification(
                        "Backup Client",
                        "start python webserver for backup! (2 mins left until start)",
                        5, "assets/icons/backup.ico", 1)

                self.logger_backup.warning(
                    f"server: {self.server_http_url} is OFFLINE (this time sleeping 2 minutes)"
                )
                sleep(2 * 60)

            # last chance
            if not self.is_server_online():
                self.logger_backup.exception(
                    f"server: {self.server_http_url} is OFFLINE")
                raise ConnectionError(
                    f"server: {self.server_http_url} is OFFLINE")

            distance = len(files_collection)
            backup_progress = progress_bar(iterable=range(distance),
                                           desc="backup_to_server",
                                           total=distance,
                                           unit="file",
                                           ncols=120)

            self.logger_backup.info(
                f"\nBackup to: {self.server_http_url} started at: {get_current_datetime()}\n"
            )
            if less_24_mode:
                self.logger_backup.info("copying less 24 files ...")
            else:
                self.logger_backup.info("copying all files ...")

            backup_start_time = time()
            total_exception_during_backup = 0
            iterator = 0
            while iterator < distance:
                try:
                    self.copy_quiet(files_collection[iterator].file,
                                    files_collection[iterator].dirname)
                    backup_progress.update(1)

                except Exception as error:
                    total_exception_during_backup += 1
                    self.logger_backup.exception(
                        f"\nexception occured at index={iterator}\nfile: {self.files_collection[iterator].file}\ndirname: {self.files_collection[iterator].dirname}\n",
                        print__=False)

                    backup_progress.update(-1)
                    iterator -= 1

                iterator += 1

            backup_progress.close()

            self.logger_backup.info(
                f"{total_exception_during_backup} exceptions occured during backup (see them in log)"
            )
            self.logger_backup.info(
                f"\nBackup to: {self.server_http_url} ended at: {get_current_datetime()}"
            )

        backup_duration = seconds_to_time(int(time() - backup_start_time))
        self.logger_backup.info(f"\nbackup duration: {backup_duration}")

        if windows:
            windows_notification("Backup Client",
                                 f"backup finished:\n({backup_duration})", 5,
                                 "assets/icons/backup.ico", 1)

        size_in_bytes = 0
        for file in files_collection:
            try:
                size_in_bytes += os.path.getsize(file)
            except (FileNotFoundError, PermissionError):
                pass

        total_size = convert_size_in_bytes(size_in_bytes)
        orig_seconds = backup_duration.seconds
        orig_minutes = backup_duration.minutes
        try:
            orig_hours = backup_duration.hours
        except AttributeError:
            orig_hours = 0

        try:
            orig_minutes = backup_duration.minutes
        except AttributeError:
            orig_minutes = 0

        hours = orig_hours + orig_minutes / 60 + orig_seconds / 3600
        minutes = orig_hours * 60 + orig_minutes + orig_seconds / 60
        seconds = orig_hours * 3600 + orig_minutes * 60 + orig_seconds

        metadata = {
            "started_datetime": backup_start_datetime,
            "finish_datetime": backup_finish_datetime,
            "total_files": len(files_collection),
            "total_size": f"{total_size[0]}{total_size[1]}",
            "total_size_in_bytes": size_in_bytes,
            "total_exceptions": 0,
            "process_interrupted": False,
            "process_interrupted_times": 0,
            "duration_hours": fixed_set_precision_float(hours, 3),
            "duration_minutes": fixed_set_precision_float(minutes, 3),
            "duration_seconds": fixed_set_precision_float(seconds, 3)
        }

        metadata_name = f"backup_metadata_{get_current_date()}_{get_current_time().replace(':', '.')}.json"
        # remote location
        write_json_to_file(metadata,
                           current_date_remote_metadata_folder / metadata_name)

        # local project
        write_json_to_file(metadata, metadata_folder / metadata_name)
Exemplo n.º 8
0
def AddAccount():
    """ adds new account to database.

        if the domain name is already existent
        then the user should enter a sub account and
        add it to the domain name in database.

        else
        creates a new domain name and adds a sub account to it.
    """

    clearscreen()
    print(add_new_account_red + "\n")
    print("enter credentials for your new account:\n")

    domain_name = input("domain name:\n>>> ")
    if domain_name == "":
        return

    domain_name = domain_name.strip().lower()

    already_existent = 0
    for dom in database.keys():
        if domain_name == dom:
            print(ConsoleColored("warning", "red", bold=1))
            print("this domain name already exists!!!\n")
            already_existent = 1
            break

    if already_existent:
        sub_account = {"email": fixed_email, "password": RandomPassword()}

        print("this is your new account that will be added to {}.\n".format(
            domain_name))
        PrintPrettify(sub_account)

        print("your domain name will look like this:\n")
        domain_copy = database[domain_name].copy()
        domain_copy.append(sub_account)
        domain_copy = {domain_name: domain_copy}
        PrintPrettify(domain_copy)

        decision = input("\nare you sure about this? [y/n]:\n")
        if decision == "y":
            database[domain_name].append(sub_account)
            print("\n" + ConsoleColored(
                "database updated successfully!", "green", bold=1))

            windows_notification("Password Manager",
                                 "password copied to clipboard!", 2,
                                 "icons\exec.ico", 1)
            pyperclip.copy(sub_account["password"])

    else:
        domain_account = {
            domain_name: [{
                "email": fixed_email,
                "password": RandomPassword()
            }]
        }

        while 1:
            PrintPrettify(domain_account)
            print()

            credentials_key = input("add key type:\n>>> ")
            if credentials_key == "":
                break

            if credentials_key == "email" or credentials_key == "password":
                print("those already exist!")
                continue

            credentials_value = input(f"{credentials_key}: ")
            domain_account[domain_name][0].update(
                {credentials_key: credentials_value})

            decision = input("\nare you done? [y/n]:\n")
            if decision == "y":
                break

        print("your new account looks like this:\n")
        PrintPrettify(domain_account)

        decision = input(
            "are you sure you want to add this to database? [y/n]:\n")
        if decision == "y":
            database.update(domain_account)
            print("\n" + ConsoleColored(
                "database updated successfully!", "green", bold=1))

            windows_notification("Password Manager",
                                 "password copied to clipboard!", 2,
                                 "icons\exec.ico", 1)
            pyperclip.copy(domain_account[domain_name][0]["password"])

    pauseprogram()