Ejemplo n.º 1
0
 def to_dict(self):
     time_format = config.get('main', 'time_format')
     return {
         'id': str(self.id),
         'name': self.name,
         'version': self.version,
         'stime': self.stime.strftime(config.get('main', 'time_format')) if self.stime else None,
         'ftime': self.ftime.strftime(config.get('main', 'time_format')) if self.ftime else None,
         'duration': self.duration.seconds if self.duration else None,
         'rollback': self.rollback,
         'status': self.status,
         'diff_url': self.diff_url,
     }
Ejemplo n.º 2
0
 def stop(self):
     """
     Mark a release as stopped
     """
     self.ftime = arrow.now(config.get('main', 'time_zone'))
     td = self.ftime - self.stime
     self.duration = td
Ejemplo n.º 3
0
def setup_database(args):
    from orlo.orm import db
    from orlo.config import config

    if config.get('db', 'uri') == 'sqlite://':
        print("Warning: setting up in-memory database, this is "
              "probably not what you want!\n"
              "Please configure db:uri in /etc/orlo/orlo.ini")
    db.create_all()
Ejemplo n.º 4
0
    def to_dict(self):
        time_format = config.get('main', 'time_format')

        metadata = {}
        for m in self.metadata:
            metadata.update(m.to_dict())

        return {
            'id': str(self.id),
            'packages': [p.to_dict() for p in self.packages],
            'platforms': [platform.name for platform in self.platforms],
            'references': string_to_list(self.references),
            'stime': self.stime.strftime(config.get('main', 'time_format')) if self.stime else None,
            'ftime': self.ftime.strftime(config.get('main', 'time_format')) if self.ftime else None,
            'duration': self.duration.seconds if self.duration else None,
            'metadata': metadata,
            'user': self.user,
            'team': self.team,
        }
Ejemplo n.º 5
0
    def stop(self, success):
        """
        Mark a package deployment as stopped

        :param success: Whether or not the package deploy succeeded
        """
        if self.stime is None:
            raise OrloWorkflowError("Can not stop a package which has not been started")
        self.ftime = arrow.now(config.get('main', 'time_zone'))

        td = self.ftime - self.stime
        self.duration = td

        if success:
            self.status = 'SUCCESSFUL'
        else:
            self.status = 'FAILED'
Ejemplo n.º 6
0
 def start(self):
     """
     Mark a package deployment as started
     """
     self.stime = arrow.now(config.get('main', 'time_zone'))
     self.status = 'IN_PROGRESS'
Ejemplo n.º 7
0
 def start(self):
     """
     Mark a release as started
     """
     self.stime = arrow.now(config.get('main', 'time_zone'))
Ejemplo n.º 8
0
from sqlalchemy_utils.types.uuid import UUIDType
from sqlalchemy_utils.types.arrow import ArrowType

from orlo import app, config
from orlo.exceptions import OrloWorkflowError
import pytz
import uuid
import arrow
import json

__author__ = 'alforbes'

db = SQLAlchemy(app)

try:
    TIMEZONE = pytz.timezone(config.get('main', 'time_zone'))
except pytz.exceptions.UnknownTimeZoneError:
    app.logger.critical(
        'Unknown time zone "{}", see pytz docs for valid values'.format(
            config.get('main', 'timezone')
        ))


# Map releases to platforms
release_platform = db.Table(
    'release_platform', db.Model.metadata,
    db.Column('release_id', UUIDType, db.ForeignKey('release.id')),
    db.Column('platform_id', UUIDType, db.ForeignKey('platform.id'))
)