From 18f719fb6d07b43992bb9dd4cca810b3f3a13bea Mon Sep 17 00:00:00 2001 From: evilhero Date: Wed, 31 Oct 2012 12:03:15 -0400 Subject: [PATCH] Fix for comiclocation error on adding new series (directory creation). Also fixed for ',' in directory creation. --- mylar/importer.py | 13 ++++++++----- mylar/webserve.py | 24 +++++++++++++----------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/mylar/importer.py b/mylar/importer.py index 2bad18fa..bcac5608 100755 --- a/mylar/importer.py +++ b/mylar/importer.py @@ -115,12 +115,14 @@ def addComictoDB(comicid,mismatch=None): # setup default location here if comlocation is None: - if ':' in comic['ComicName'] or '/' in comic['ComicName']: + if ':' in comic['ComicName'] or '/' in comic['ComicName'] or ',' in comic['ComicName']: comicdir = comic['ComicName'] if ':' in comicdir: comicdir = comicdir.replace(':','') if '/' in comicdir: comicdir = comicdir.replace('/','-') + if ',' in comicdir: + comicdir = comicdir.replace(',','') else: comicdir = comic['ComicName'] series = comicdir @@ -445,13 +447,14 @@ def GCDimport(gcomicid): #comic book location on machine # setup default location here if comlocation is None: - if ':' in ComicName or '/' in ComicName: + if ':' in ComicName or '/' in ComicName or ',' in ComicName: comicdir = ComicName if ':' in comicdir: comicdir = comicdir.replace(':','') if '/' in comicdir: comicdir = comicdir.replace('/','-') - + if ',' in comicdir: + comicdir = comicdir.replace(',','') else: comicdir = ComicName comlocation = mylar.DESTINATION_DIR + "/" + comicdir + " (" + ComicYear + ")" if mylar.DESTINATION_DIR == "": @@ -568,11 +571,11 @@ def GCDimport(gcomicid): #---END.NEW. # check if the issue already exists - iss_exists = myDB.select('SELECT * from issues WHERE IssueID=?', [issid]) + iss_exists = myDB.action('SELECT * from issues WHERE IssueID=?', [issid]).fetchone() # Only change the status & add DateAdded if the issue is not already in the database - if not len(iss_exists): + if iss_exists is None: newValueDict['DateAdded'] = helpers.today() #adjust for inconsistencies in GCD date format - some dates have ? which borks up things. diff --git a/mylar/webserve.py b/mylar/webserve.py index 102b8a64..44c6a8bc 100755 --- a/mylar/webserve.py +++ b/mylar/webserve.py @@ -62,19 +62,21 @@ class WebInterface(object): myDB = db.DBConnection() comic = myDB.action('SELECT * FROM comics WHERE ComicID=?', [ComicID]).fetchone() issues = myDB.select('SELECT * from issues WHERE ComicID=? order by Int_IssueNumber DESC', [ComicID]) - # make sure comic dir exists.. - comlocation = comic['ComicLocation'] - if os.path.isdir(str(comlocation)): pass - #logger.info(u"Directory (" + str(comlocation) + ") already exists! Continuing...") - else: - print ("Directory doesn't exist!") - try: - os.makedirs(str(comlocation)) - logger.info(u"No directory found - So I created one at: " + str(comlocation)) - except OSError: - logger.error(u"Could not create directory for comic : " + str(comlocation)) if comic is None: raise cherrypy.HTTPRedirect("home") + else: + # make sure comic dir exists.. + comlocation = comic['ComicLocation'] + if os.path.isdir(str(comlocation)): pass + #logger.info(u"Directory (" + str(comlocation) + ") already exists! Continuing...") + else: + print ("Directory doesn't exist!") + try: + os.makedirs(str(comlocation)) + logger.info(u"No directory found - So I created one at: " + str(comlocation)) + except OSError: + logger.error(u"Could not create directory for comic : " + str(comlocation)) + comicConfig = { "comiclocation" : mylar.COMIC_LOCATION }