Browse Source

Add initialisation of working dir

develop
Jonathan Golder 4 years ago
parent
commit
29c5d725f1
  1. 25
      euroexange/euroexange.py

25
euroexange/euroexange.py

@ -26,14 +26,39 @@ import jogobot
class EuroExangeBot( pywikibot.bot.BaseBot ):
working_dir = os.path.dirname(os.path.realpath(__file__)) + "/../wdir"
def __init__( self, genFactory, **kwargs ):
self.init_wdir()
super().__init__(*kwargs)
def run(self):
pass
def init_wdir(self):
"""
Make sure, the working directory exists
"""
#Normalize working dir
self.wdir = os.path.realpath(type(self).working_dir)
if os.path.exists(self.wdir):
if os.path.isdir(self.wdir):
return
else:
raise OSError("Working directory at {} already exists, but is no directory".format(
self.wdir))
else:
os.makedirs( self.wdir )
jogobot.output( "Create empty working directory at {}".format(
self.wdir))
def main(*args):
"""

Loading…
Cancel
Save