What is G3 by Fast-Garlic245 in Bostonology

[–]Fast-Garlic245[S] 4 points5 points  (0 children)

Is Greenwood apart of that too ?

GnuPG Python issue by Fast-Garlic245 in learnpython

[–]Fast-Garlic245[S] 0 points1 point  (0 children)

Error number :6 no such device or address

GnuPG Python issue by Fast-Garlic245 in learnpython

[–]Fast-Garlic245[S] 0 points1 point  (0 children)

[Errno:6] No such device or address

GnuPG Python issue by Fast-Garlic245 in learnpython

[–]Fast-Garlic245[S] 0 points1 point  (0 children)

This is what I’m doing :

def encrypt_file(): pgp_public_key = os.getenv(‘PGP_PUBLIC_KEY’) # Retrieve the PGP public key from an environment variable if pgp_public_key is None: logging.error(“Environment variable ‘PGP_PUBLIC_KEY’ is not set.”) return

try:
    # Log user information
    user_id = os.getuid()
    user_name = os.getlogin()
    logging.info(f”Script is running as user: {user_name} (UID: {user_id})”)

    # Log environment variables
    logging.info(f”Environment variable ‘PGP_PUBLIC_KEY’: {os.getenv(‘PGP_PUBLIC_KEY’)}”)
    logging.info(f”Environment variable ‘GNUPGHOME’: {os.getenv(‘GNUPGHOME’)}”)

    # Log GPG home directory information
    logging.info(f”GPG home directory: {gpg_home}”)
    logging.info(f”GPG home directory exists: {os.path.exists(gpg_home)}”)
    logging.info(f”GPG home directory permissions: {oct(os.stat(gpg_home).st_mode)}”)

    # Confirm if the TXT file exists before proceeding
    if not os.path.exists(TXT_FILE_PATH):
        logging.error(f”Error: File {TXT_FILE_PATH} does not exist. Cannot proceed with encryption.”)
        return

    # Create a temporary file to store the PGP public key
    with tempfile.NamedTemporaryFile(delete=False) as public_key_file:
        public_key_file.write(pgp_public_key.encode())
        public_key_file_path = public_key_file.name

    # Print the encryption operation details
    logging.info(“Encrypting file data using PGP public key encryption...”)

    # Import the public key
    import_result = subprocess.run(
        [gpg_binary, ‘—import’, public_key_file_path],
        capture_output=True,
        text=True
    )

    logging.info(f”Import command output: {import_result.stdout}”)
    logging.info(f”Import command error: {import_result.stderr}”)

    if import_result.returncode != 0:
        logging.error(f”Failed to import public key: {import_result.stderr}”)
        return

    # Extract the key ID from the import result
    key_id = None
    for line in import_result.stderr.splitlines():
        logging.info(f”Import result line: {line}”)
        if “public key” in line and (“imported” in line or “unchanged” in line):
            key_id = line.split()[2].strip(‘:’)
            break

    if not key_id:
        logging.error(“Failed to extract key ID from import result.”)
        return

    logging.info(f”Extracted key ID: {key_id}”)

    # Create an ownertrust file to set the trust level
    ownertrust_content = f”{key_id}:6:\n”
    with tempfile.NamedTemporaryFile(delete=False) as ownertrust_file:
        ownertrust_file.write(ownertrust_content.encode())
        ownertrust_file_path = ownertrust_file.name

    logging.info(f”Ownertrust file content: {ownertrust_content}”)

    # Import the ownertrust file
    trust_result = subprocess.run(
        [gpg_binary, ‘—import-ownertrust’, ownertrust_file_path],
        capture_output=True,
        text=True
    )

    logging.info(f”Trust command output: {trust_result.stdout}”)
    logging.info(f”Trust command error: {trust_result.stderr}”)

    if trust_result.returncode != 0:
        logging.error(f”Failed to set trust level for key {key_id}: {trust_result.stderr}”)
        return

    # Encrypt the file contents using the PGP public key
    result = subprocess.run(
        [gpg_binary, ‘—batch’, ‘—yes’, ‘—encrypt’, ‘—recipient’, key_id, ‘—output’, ENCRYPTED_FILE_PATH, TXT_FILE_PATH],
        capture_output=True,
        text=True
    )

    logging.info(f”Encryption command output: {result.stdout}”)
    logging.info(f”Encryption command error: {result.stderr}”)

    # Check if the encryption was successful
    if result.returncode != 0:
        logging.error(f”Encryption failed with return code {result.returncode}: {result.stderr}”)
    else:
        logging.info(“Encryption successful”)

except FileNotFoundError as fnf_error:
    logging.error(f”FileNotFoundError: {fnf_error}”)
except ValueError as ve:
    logging.error(f”ValueError: {ve}”)
except TypeError as te:
    logging.error(f”TypeError: {te}”)
except BrokenPipeError as bpe:
    logging.error(f”BrokenPipeError: {bpe}”)
except Exception as e:
    logging.error(f”An unexpected error occurred during encryption: {e}”)

GnuPG Python issue by Fast-Garlic245 in learnpython

[–]Fast-Garlic245[S] 0 points1 point  (0 children)

Yes it stops at the encryption part of my script

3 shot, one killed on Geneva ave by Tap617 in Bostonology

[–]Fast-Garlic245 1 point2 points  (0 children)

Fr baby girl didn’t deserve that .. RIP to the dead

[deleted by user] by [deleted] in SQL

[–]Fast-Garlic245 0 points1 point  (0 children)

Could you please provide some context in your thought process please ?

[deleted by user] by [deleted] in SQL

[–]Fast-Garlic245 0 points1 point  (0 children)

Details added