Add initialisation of working dir
This commit is contained in:
@@ -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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user