Skip to content

Commit

Permalink
gracefully handle nonexisting dump dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Kroll committed Jan 16, 2015
1 parent 4abbab5 commit f1b5777
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions graphcare.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,19 +279,22 @@ def LoadAllGraphs(servconfig):
conn.authorize('password', '%s:%s' % (str(servconfig.graphservUser), str(servconfig.graphservPassword)))

dumpdir= os.path.join(servconfig.graphservWorkDir, 'dumps')
for f in os.listdir(dumpdir):
graphname= os.path.splitext(f)[0]
try:
conn.use_graph(graphname)
log('clearing existing graph %s.' % graphname)
conn.clear()
except client.gpProcessorException:
log('creating graph %s.' % graphname)
conn.create_graph(graphname)
conn.use_graph(graphname)
filename= os.path.join(dumpdir, f)
log('loading graph %s from %s.' % (graphname, filename))
conn.load_graph(filename)
if not os.path.isdir(dumpdir):
log('no such directory %s.' % dumpdir)
else:
for f in os.listdir(dumpdir):
graphname= os.path.splitext(f)[0]
try:
conn.use_graph(graphname)
log('clearing existing graph %s.' % graphname)
conn.clear()
except client.gpProcessorException:
log('creating graph %s.' % graphname)
conn.create_graph(graphname)
conn.use_graph(graphname)
filename= os.path.join(dumpdir, f)
log('loading graph %s from %s.' % (graphname, filename))
conn.load_graph(filename)

conn.close()
log('done.')
Expand Down

0 comments on commit f1b5777

Please sign in to comment.