Skip to content

Commit c51c4ff

Browse files
author
aoberrender
committed
removed bash attempt, and offset date from printer counter, because the only reason why printer finder has a offset option is for assuming it takes an hour to scan a subnet.
1 parent 9aa45be commit c51c4ff

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

src/_find_printers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import time
77

88

9+
10+
911
from more_python.time_formatter import format_elapsed_time
1012
timestart = datetime.now()
1113

src/_printer_counter.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,38 +29,24 @@
2929
debug = config.get('debug', False)
3030
known_printers = config.get('knownprinters', [])
3131
snmpv1_community = config['snmpv1_community']
32-
bash_commands = config['bashCommands']
3332
###############################################
3433

35-
# Function to execute a given bash command
36-
def execute_command(command_name):
37-
command = bash_commands.get(command_name)
38-
if command:
39-
result = subprocess.run(command, shell=True, capture_output=True, text=True)
40-
print(f"Output for {command_name}:\n{result.stdout}")
41-
print(f"Error for {command_name}:\n{result.stderr}")
42-
else:
43-
print(f"Command {command_name} not found in the configuration.")
44-
45-
execute_command('StartBashCounter')
4634

4735
# Get the base date
4836
base_date = datetime.now()
4937
if config.get('debug_date', False):
5038
base_date = datetime.strptime(f"01-{config.get('debug_MM_YYYY', required=False)}", "%d-%m-%Y")
5139

52-
# Calculate the adjusted date based on offset
53-
date_filename_offset = -config.get('DateFilenameOffset', 0)
54-
adjusted_date = base_date + timedelta(days=date_filename_offset)
55-
adjusted_year = adjusted_date.strftime("%Y")
40+
# Calculate the adjusted date based on offset
41+
adjusted_year = base_date.strftime("%Y")
5642

5743
# Create a subdirectory for the year
5844
year_output_dir = os.path.join(output_directory, adjusted_year)
5945
os.makedirs(year_output_dir, exist_ok=True)
6046

6147

6248
# Define the filename with the requested naming scheme
63-
filename = f"totals_{adjusted_date:%Y_%m}.csv"
49+
filename = f"totals_{base_date:%Y_%m}.csv"
6450
csvfile_path = os.path.join(year_output_dir, filename)
6551
logfile = os.path.join(year_output_dir, "TodaysLog_PrinterCounter.txt")
6652

@@ -151,7 +137,7 @@ def try_snmp_get(ip, oids):
151137
current_month = datetime.now().month
152138

153139
# Format the expected file name
154-
foundPrintersCSV = f"foundprinters_{adjusted_date:%Y-%m}.csv"
140+
foundPrintersCSV = f"foundprinters_{base_date:%Y-%m}.csv"
155141
foundprinters_dir = os.path.normpath(os.path.join(script_dir, f"../{output_name}"))
156142
echo = f"searching: {foundprinters_dir}"
157143
expected_file_path = os.path.join(year_output_dir, foundPrintersCSV)
@@ -287,5 +273,4 @@ def try_snmp_get(ip, oids):
287273
timeend = datetime.now()
288274
elapsed_time = timeend - timestart
289275
formatted_elapsed_time = format_elapsed_time(elapsed_time, format_type=1)
290-
print(f"All done in {elapsed_time} seconds")
291-
execute_command('EndBashCounter')
276+
print(f"All done in {elapsed_time} seconds")

src/more_python/customCliColors.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# customCliColors.py
2+
3+
class color:
4+
# Define your custom colors here
5+
R = '\033[91m' # Red
6+
G = '\033[92m' # Green
7+
B = '\033[94m' # Blue
8+
C = '\033[96m' # Cyan
9+
Y = '\033[93m' # Yellow
10+
M = '\033[95m' # Magenta
11+
K = '\033[96m' # Black
12+
P = '\033[95m' # Purple
13+
WHITE = '\033[97m'
14+
RESET = '\033[0m'
15+
16+
__module__ = "customCliColors"
17+
18+
# Usage example
19+
#print(color.R + "This text is in red color!" + color.RESET)
20+
#print(color.G + "This text is in green color!" + color.RESET)
21+
22+

0 commit comments

Comments
 (0)