From 33d34661d905b548e524985aa3c12b90642ab47c Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 7 Feb 2025 14:23:48 -0500 Subject: [PATCH] automated terminal push --- consumer (copy 2).py | 17 +++++++++++++++ consumer (copy 3).py | 17 +++++++++++++++ consumer (copy 4).py | 17 +++++++++++++++ consumer.py | 51 +++++++++++++++++++++++++++++++++----------- file.dat | 2 ++ schedule.py | 44 ++++++++++++++++++++++++++++++++++++++ sdf | 0 7 files changed, 136 insertions(+), 12 deletions(-) create mode 100644 consumer (copy 2).py create mode 100644 consumer (copy 3).py create mode 100644 consumer (copy 4).py create mode 100644 file.dat create mode 100644 schedule.py create mode 100644 sdf diff --git a/consumer (copy 2).py b/consumer (copy 2).py new file mode 100644 index 0000000..8577230 --- /dev/null +++ b/consumer (copy 2).py @@ -0,0 +1,17 @@ + + +print("## ") +print("## starting > JMS consumer (yankee-sully-channels-monthly)") +print("## ") + + + + + + + + +print("## ") +print("## notification > connected to JMS server (yankee-sully-channels-monthly)") +print("## ") + diff --git a/consumer (copy 3).py b/consumer (copy 3).py new file mode 100644 index 0000000..8577230 --- /dev/null +++ b/consumer (copy 3).py @@ -0,0 +1,17 @@ + + +print("## ") +print("## starting > JMS consumer (yankee-sully-channels-monthly)") +print("## ") + + + + + + + + +print("## ") +print("## notification > connected to JMS server (yankee-sully-channels-monthly)") +print("## ") + diff --git a/consumer (copy 4).py b/consumer (copy 4).py new file mode 100644 index 0000000..8577230 --- /dev/null +++ b/consumer (copy 4).py @@ -0,0 +1,17 @@ + + +print("## ") +print("## starting > JMS consumer (yankee-sully-channels-monthly)") +print("## ") + + + + + + + + +print("## ") +print("## notification > connected to JMS server (yankee-sully-channels-monthly)") +print("## ") + diff --git a/consumer.py b/consumer.py index 8577230..d58181d 100644 --- a/consumer.py +++ b/consumer.py @@ -1,17 +1,44 @@ +def write_to_file(filepath, content): + """Writes content to a file. + + Args: + filepath: The path to the file. + content: The string to write to the file. + Returns: + True on success, False on failure. Prints error messages. + """ + try: + with open(filepath, 'w') as f: # 'w' mode overwrites, 'a' appends + f.write(content) + return True + except OSError as e: + print(f"Error writing to file {filepath}: {e}") + return False -print("## ") -print("## starting > JMS consumer (yankee-sully-channels-monthly)") -print("## ") +# Example usage: +filepath = "/tmp/file.dat" # Or any path you want +content = "yooo" + +if write_to_file(filepath, content): + print(f"Successfully wrote '{content}' to {filepath}") +else: + print("File write operation failed.") +# Example of appending: +def append_to_file(filepath, content): + """Appends content to a file.""" + try: + with open(filepath, 'a') as f: # 'a' mode appends + f.write(content) + return True + except OSError as e: + print(f"Error appending to file {filepath}: {e}") + return False - - - - - -print("## ") -print("## notification > connected to JMS server (yankee-sully-channels-monthly)") -print("## ") - +# Example usage of append: +if append_to_file(filepath, "\nand more yooo"): # \n for a new line + print("Successfully appended to the file.") +else: + print("File append operation failed.") diff --git a/file.dat b/file.dat new file mode 100644 index 0000000..393994f --- /dev/null +++ b/file.dat @@ -0,0 +1,2 @@ +yooo +and more yooo \ No newline at end of file diff --git a/schedule.py b/schedule.py new file mode 100644 index 0000000..d58181d --- /dev/null +++ b/schedule.py @@ -0,0 +1,44 @@ +def write_to_file(filepath, content): + """Writes content to a file. + + Args: + filepath: The path to the file. + content: The string to write to the file. + Returns: + True on success, False on failure. Prints error messages. + """ + try: + with open(filepath, 'w') as f: # 'w' mode overwrites, 'a' appends + f.write(content) + return True + except OSError as e: + print(f"Error writing to file {filepath}: {e}") + return False + + +# Example usage: +filepath = "/tmp/file.dat" # Or any path you want +content = "yooo" + +if write_to_file(filepath, content): + print(f"Successfully wrote '{content}' to {filepath}") +else: + print("File write operation failed.") + + +# Example of appending: +def append_to_file(filepath, content): + """Appends content to a file.""" + try: + with open(filepath, 'a') as f: # 'a' mode appends + f.write(content) + return True + except OSError as e: + print(f"Error appending to file {filepath}: {e}") + return False + +# Example usage of append: +if append_to_file(filepath, "\nand more yooo"): # \n for a new line + print("Successfully appended to the file.") +else: + print("File append operation failed.") diff --git a/sdf b/sdf new file mode 100644 index 0000000..e69de29