-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobs.py
74 lines (63 loc) · 2.71 KB
/
globs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#####
#
# Module name: globs.py
# Purpose: Global object repository for use by dupReport program
#
#####
import os
# Define version info
version=[2,2,12] # Program Version
status='Release'
dbVersion=[1,0,3] # Required DB version
rcVersion=[3,0,0] # Required RC version
copyright='Copyright (c) 2020 Stephen Fried for HandyGuy Software.'
# Define global variables
dbName='dupReport.db' # Default database name
logName='dupReport.log' # Default log file name
rcName='dupReport.rc' # Default configuration file name
tmpName = 'duplog.tmp'
db = None # Global database object
dateFormat = None # Global date format - can be overridden per backup set
timeFormat = None # Global time format - can be overridden per backup set
report = None # Global report object
ofileList = None # List of output files
optionManager = None # Option Manager
opts = None # Global program options
progPath = None # Path to script files
appriseObj = None # dupApprise instance
# Text & format fields for report email
emailText=[] # List of email text components
emailFormat=[] # Corresponding list of emial components print formats
# Global variables referencing objects in other modules
log = None # Log file handling
inServer = None # Inbound email server
outServer = None # Outbound email server
# Mask sensitive data in log files
# Replace incoming string with string of '*' the same length of the original
def maskData(inData, force = False):
if inData is None: # Empty input or global options haven't been processed yet. Return unmasked input.
return inData
elif force: # Mask regardless of what parameter says. Useful if masking before options are processed.
return "*" * len(inData)
elif opts is None:
return inData
elif 'masksensitive' in opts and opts['masksensitive'] is True:
return "*" * len(inData) # Mask data.
else:
return inData # Return unmasked input
# Close everything and exit cleanly
def closeEverythingAndExit(errcode):
log.write(1,'Closing everything...')
if inServer is not None:
log.write(1,'Closing inbound email server...')
inServer.close()
if outServer is not None:
log.write(1,'Closing outbound email server...')
outServer.close()
if db is not None:
log.write(1,'Closing database file...')
db.dbClose()
if log is not None:
log.write(1,'Closing log file...')
log.closeLog()
os._exit(errcode)