コード例 #1
0
def task_savelogs():
    '''
    save the logs to a timestamped file
    '''
    timestamp = datetime2int(utcnow())

    return {
        'task_dep': ['checkreqs', 'dockercompose'],
        'actions': [
            f'mkdir -p {LOGDIR}',
            f'cd {PROJDIR} && docker-compose logs > {LOGDIR}/{timestamp}.log',
        ]
    }
コード例 #2
0
ファイル: bundle.py プロジェクト: gozer/autocert
class BundleProperties(type):
    '''
    Bundle properties
    properties on classmethods https://stackoverflow.com/a/47334224
    '''

    zero = timedelta(0)

    timestamp = timestamp.utcnow()

    bundle_path = str(CFG.bundle.path)

    readme = open(
        os.path.dirname(os.path.abspath(__file__)) + '/README.tarfile').read()

    @property
    def files(cls):
        return glob.glob(cls.bundle_path + '/*.tar.gz')

    @property
    def names(cls):
        def get_bundle_name(bundle_file):
            ext = '.tar.gz'
            if bundle_file.startswith(
                    cls.bundle_path) and bundle_file.endswith(ext):
                return os.path.basename(bundle_file)[0:-len(ext)]

        return [get_bundle_name(bundle_file) for bundle_file in cls.files]

    def bundles(cls, bundle_name_pns, within=None, expired=False):
        bundles = []
        if isint(within):
            within = timedelta(within)
        for bundle_name in sorted(sift.fnmatches(cls.names, bundle_name_pns)):
            bundle = Bundle.from_disk(bundle_name, bundle_path=cls.bundle_path)
            if bundle.sans:
                bundle.sans = sorted(bundle.sans)
            if within:
                delta = bundle.expiry - cls.timestamp
                if cls.zero < delta and delta < within:
                    bundles += [bundle]
            elif expired:
                if bundle.expiry < cls.timestamp:
                    bundles += [bundle]
            elif bundle.expiry > cls.timestamp:
                bundles += [bundle]
        return bundles
コード例 #3
0
ファイル: base.py プロジェクト: danielhartnell/autocert
 def __init__(self, cfg, args):
     self.timestamp = timestamp.utcnow()
     self.ar = AsyncRequests()
     self.cfg = AttrDict(cfg)
     self.args = AttrDict(args)
     self.verbosity = self.args.verbosity
     authorities = self.cfg.authorities
     self.authorities = AttrDict({
         a: create_authority(a, self.ar, authorities[a], self.verbosity)
         for a in authorities
     })
     destinations = self.cfg.destinations
     self.destinations = AttrDict({
         d: create_destination(d, self.ar, destinations[d], self.verbosity)
         for d in destinations
     })
     self.tardata = Tardata(self.cfg.tar.dirpath, self.verbosity)
コード例 #4
0
ファイル: test_bundle.py プロジェクト: gozer/autocert
# -*- coding: utf-8 -*-

import os
import pytest

from subprocess import check_output

from utils import timestamp
from bundle import Bundle

DIR = os.path.dirname(os.path.realpath(__file__))
KEY = open(DIR+'/key').read()
CSR = open(DIR+'/csr').read()
CRT = open(DIR+'/crt').read()

EXPIRY = timestamp.utcnow()
TIMESTAMP = timestamp.utcnow()

@pytest.fixture
def bundle():
    return Bundle(
        'common.name',
        'e8a7fcfbe48df21daede665d78984dec',
        KEY,
        CSR,
        CRT,
        '0000000',
        expiry=EXPIRY,
        authority=dict(digicert=dict(order_id=1298368)),
        timestamp=TIMESTAMP)
コード例 #5
0
 def __init__(self, tarpath, verbosity):
     self._timestamp = timestamp.utcnow()
     self._tarpath = str(tarpath)
     self.verbosity = verbosity