From: Holger Levsen Date: Wed, 2 Nov 2011 10:54:37 +0000 (+0100) Subject: use correct spelling X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=9ea442d486e73348ce0346e97374c633ac6e11b8;p=profitbricks%2Fjenkins-build-scripts.git use correct spelling --- diff --git a/kernel_build.py b/kernel_build.py index 7ae3903..b9b6eec 100644 --- a/kernel_build.py +++ b/kernel_build.py @@ -11,7 +11,7 @@ import logging import smtplib from glob import glob from logging import Formatter -import kernel_persistance +import kernel_persistence CWD = os.environ.get('WORKSPACE') BUILD_NUMBER = os.environ.get('BUILD_NUMBER') @@ -139,7 +139,7 @@ if __name__ == '__main__': atexit.register(remove_git_target_workspace) kernel_revision_obj = kernel_persistence.get_last_kernel_revision_obj() new_version = kernel_revision_obj.last_version + 1 - if not kernel_persistance.update_kernel_revision_obj(kernel_revision_obj, new_version): + if not kernel_persistence.update_kernel_revision_obj(kernel_revision_obj, new_version): logger.info( 'Could not update persistence version to %s for %s' %(new_version, GIT_BRANCH_NAME) diff --git a/kernel_persistance.py b/kernel_persistance.py deleted file mode 100644 index e0d9c9a..0000000 --- a/kernel_persistance.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -from sqlalchemy import create_engine -from sqlalchemy.orm import sessionmaker -from sqlalchemy import Table, Column, Integer, String, MetaData, Sequence -from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm.exc import NoResultFound - -CWD = os.environ.get('WORKSPACE') -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) - -class KernelVersion(Base): - __tablename__ = 'branch_kernel_version' - id = Column(Integer, Sequence('branch_id'), primary_key=True) - identifier = Column(String(255), unique=True, nullable=False) - branch_name = Column(String(255), unique=True, nullable=False) - last_version = Column(Integer, nullable=False) - pb_modules = Column(String(255), unique=True, nullable=False) - - def __init__(self, branch_name, last_version): - self.identifier = identifier - self.last_version = last_version - self.branch_name = branch_name - self.pb_modules = pb_modules - - def __repr__(self): - return '' %( - self.identifier, self.last_version - ) - -def get_last_kernel_revision_obj(): - session = Session() - logger.debug('Getting kernel revision from persistence') - if GIT_BRANCH_NAME == 'master' or GIT_BRANCH_NAME.startswith('hotfix'): - persistance_identifier = 'master' - elif GIT_BRANCH_NAME.startswith('release'): - persistance_identifier = 'release' - else: - # FIXME: feature branch handling - persistance_identifier = 'develop' - - try: - answ = session.query(KernelVersion).filter( - KernelVersion.identifier == persistance_identifier).one() - except NoResultFound: - session.add(KernelVersion(persistance_identifier, 0)) - session.commit() - answ = session.query(KernelVersion).filter( - KernelVersion.identifier == persistance_identifier).one() - finally: - session.close() - - logger.info( - 'Got this Kernel revision for persistance_identifier %s: %s' - %(persistance_identifier, answ) - ) - return answ - -def update_kernel_revision_obj(kernel_version_obj, new_revision): - session = Session() - kernel_version_obj.last_version = new_revision - session.add(kernel_version_obj) - try: - session.commit() - except Exception, error: - logger.error('Some error happend while commiting new revision') - logger.exception(error) - return False - else: - return True - finally: - session.close() diff --git a/kernel_persistence.py b/kernel_persistence.py new file mode 100644 index 0000000..b5542ae --- /dev/null +++ b/kernel_persistence.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker +from sqlalchemy import Table, Column, Integer, String, MetaData, Sequence +from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.orm.exc import NoResultFound + +CWD = os.environ.get('WORKSPACE') +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) + +class KernelVersion(Base): + __tablename__ = 'branch_kernel_version' + id = Column(Integer, Sequence('branch_id'), primary_key=True) + identifier = Column(String(255), unique=True, nullable=False) + branch_name = Column(String(255), unique=True, nullable=False) + last_version = Column(Integer, nullable=False) + pb_modules = Column(String(255), unique=True, nullable=False) + + def __init__(self, branch_name, last_version): + self.identifier = identifier + self.last_version = last_version + self.branch_name = branch_name + self.pb_modules = pb_modules + + def __repr__(self): + return '' %( + self.identifier, self.last_version + ) + +def get_last_kernel_revision_obj(): + session = Session() + logger.debug('Getting kernel revision from persistence') + if GIT_BRANCH_NAME == 'master' or GIT_BRANCH_NAME.startswith('hotfix'): + persistence_identifier = 'master' + elif GIT_BRANCH_NAME.startswith('release'): + persistence_identifier = 'release' + else: + # FIXME: feature branch handling + persistence_identifier = 'develop' + + try: + answ = session.query(KernelVersion).filter( + KernelVersion.identifier == persistence_identifier).one() + except NoResultFound: + session.add(KernelVersion(persistence_identifier, 0)) + session.commit() + answ = session.query(KernelVersion).filter( + KernelVersion.identifier == persistence_identifier).one() + finally: + session.close() + + logger.info( + 'Got this Kernel revision for persistence_identifier %s: %s' + %(persistence_identifier, answ) + ) + return answ + +def update_kernel_revision_obj(kernel_version_obj, new_revision): + session = Session() + kernel_version_obj.last_version = new_revision + session.add(kernel_version_obj) + try: + session.commit() + except Exception, error: + logger.error('Some error happend while commiting new revision') + logger.exception(error) + return False + else: + return True + finally: + session.close()