Skip to content

Commit

Permalink
working on improved dump_db program even more
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert McLay committed Nov 14, 2024
1 parent 98a1634 commit 7c60659
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 4 additions & 1 deletion contrib/tracking_module_usage/gen_1/LMODdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ def dump_db(self, startDate, endDate, fn):
userA = None
moduleA = None


query = ""
try:
f = open(fn, "w")
conn = self.connect()
cursor = conn.cursor()
query = "USE "+self.db()
Expand Down Expand Up @@ -176,12 +178,13 @@ def dump_db(self, startDate, endDate, fn):
modT = moduleA[int(row[1])]
date = str(row[2])
t = {'user': user, 'path': modT['path'], 'module' : modT['module'], 'syshost': modT['syshost'], 'date' : date }
print(json.dumps(t))
f:write(json.dumps(t))

except Exception as e:
print("dump_db(): ",e)
sys.exit(1)

f.close()

def data_to_db(self, debug, count, dataT, line):
"""
Expand Down
12 changes: 4 additions & 8 deletions contrib/tracking_module_usage/gen_1/dump_db
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def dbConfigFn(dbname):
def main():
args = CmdLineOptions().execute()
configFn = dbConfigFn(args.dbname)
#lmod = LMODdb(configFn)
lmod = LMODdb(configFn)

if (not os.path.isdir(args.parentDir)):
print("parentDir must exist")
Expand All @@ -95,16 +95,12 @@ def main():
fn = "lmodV2_db_"

for i in range(N):
output = args.parentDir + "/" + fn + startDateIdx.dateStr("_") + ".json"
fullFn = fn + startDateIdx.dateStr("_") + ".json"
output = os.path.join(args.parentDir, fullFn)
start = startDateIdx.dateStr("-")
end = endDateIdx.dateStr("-")
startDateIdx.incr()
endDateIdx.incr()

print (start, end, output)



#lmod.dump_db(args.startDate, args.endDate, fn)
lmod.dump_db(start, end, output)

if ( __name__ == '__main__'): main()

0 comments on commit 7c60659

Please sign in to comment.