]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
revert last commit and try something else
authorHolger Levsen <holger@layer-acht.org>
Wed, 2 Nov 2011 12:21:26 +0000 (13:21 +0100)
committerHolger Levsen <holger@layer-acht.org>
Wed, 2 Nov 2011 12:21:26 +0000 (13:21 +0100)
kernel_persistence.py

index 56a0d575459619dddfd9347b0ba91222c2a20f5a..9855604ead506fb8eb1cdf0c2faca0b9ba518d14 100644 (file)
@@ -17,7 +17,6 @@ PERSISTENCE_FILE = os.path.join(CWD, '..', '.persistence')
 Base = declarative_base()
 engine = create_engine('sqlite:///%s' %(PERSISTENCE_FILE))
 Session = sessionmaker(bind=engine)
-Base.metadata.create_all(engine)
 
 # FIXME: move this into own logger Class
 logger = logging.getLogger(sys.argv[0])
@@ -47,6 +46,8 @@ class KernelVersion(Base):
                 self.identifier, self.last_version, self.branch_name, self.pb_modules
         )
 
+Base.metadata.create_all(engine)
+
 def get_last_kernel_revision_obj(branch):
     session = Session()
     logger.debug('Getting kernel revision from persistence')
@@ -63,7 +64,7 @@ def get_last_kernel_revision_obj(branch):
     try:
         answ = session.query(KernelVersion).filter(
                 KernelVersion.identifier == persistence_identifier).one()
-    except:
+    except NoResultFound:
         session.add(KernelVersion(persistence_identifier, 0, branch, ''))
         session.commit()
         answ = session.query(KernelVersion).filter(