Exemplo n.º 1
0
 def __init__(self, raise_exceptions=False):
     logger = getLoggerWithConsoleHandler('hyde')
     super(Engine, self).__init__(raise_exceptions=raise_exceptions,
                                  logger=logger)
Exemplo n.º 2
0
 def __init__(self, raise_exceptions=False, logger=None):
     self.raise_exceptions = raise_exceptions
     self.logger = logger or getLoggerWithConsoleHandler()
Exemplo n.º 3
0
from urllib.parse import urljoin, urlparse
import re
import textwrap
from commando.util import getLoggerWithConsoleHandler
from bs4 import BeautifulSoup
from flask_gopher import GopherMenu, GopherExtension
from hyde.plugin import Plugin
from hyde.template import Template
import pypandoc
from . import _version

MENU_LINE_PATTERN = re.compile('^.+\t.*\t.*\t.*$')  # taken from flask-gopher
MARKDOWN_LINK_PATTERN = re.compile(r'\s*\[([^\]]*)\]: (.+)')
CORRUPTED_LINE_PATTERN = re.compile(r'^(.)(.+) (.+) (.+) \d+$')

logger = getLoggerWithConsoleHandler(__name__)


class Generator:
    """
    The main generator class.
    
    This mostly holds state, for now.
    """
    def __init__(self, site, gopher, gopher_menu):
        self.site = site
        self.gopher = gopher
        self.gopher_menu = gopher_menu
        plugins = Plugin(site)
        plugins.load_all(site)
        self.events = Plugin.get_proxy(site)
Exemplo n.º 4
0
Arquivo: cat.py Projeto: cnuber/gitbot
from fnmatch import fnmatch
from fswrap import File, Folder
from commando.util import getLoggerWithConsoleHandler

logger = getLoggerWithConsoleHandler('gitbot.cat')


class FILES(object):

    def __init__(self, patterns=None, replace=None):
        if not patterns:
            self.patterns = ["*"]
        elif not isinstance(patterns, (list)):
            self.patterns = [patterns]
        self.patterns = [unicode(pattern) for pattern in self.patterns]
        self.replace = replace or {}

    def walk(self, base_dir):
        return (f for f in Folder(base_dir).walker.walk_files()
                        if any(fnmatch(f.path, pattern)
                            for pattern in self.patterns))

    def walk_lines(self, base_dir):
        for file_name in self.walk(base_dir):
            with open(str(file_name), 'r') as f:
                for line in f:
                    yield line


class END(object):
    pass
Exemplo n.º 5
0
 def __init__(self, raise_exceptions=False):
     logger = getLoggerWithConsoleHandler('hyde')
     super(Engine, self).__init__(
         raise_exceptions=raise_exceptions,
         logger=logger
     )
Exemplo n.º 6
0
import actions
from commando import Application, command, store, subcommand, true, version
from fswrap import File
from commando.util import getLoggerWithConsoleHandler
import yaml


logger = getLoggerWithConsoleHandler('gitbot.builder')


class Engine(Application):

    @command(description='gitbot-builder - Create or update a gitbot stack',
        epilog='Use %(prog)s {command} -h to get help on individual commands')
    @true('-v', '--verbose', help="Show detailed information in console")
    @version('--version', version='%(prog)s ' + '0.1')
    def main(self, args):
        pass

    @subcommand('www',
        help='Generates and pushes the www project.')
    @store('-c', '--config', default='data.yaml', help="Config file")
    def www(self, args):
        data = yaml.load(File(args.config).read_all())
        actions.www(data)

    @subcommand('api',
        help='Generates and pushes the api project.')
    @store('-c', '--config', default='data.yaml', help="Config file")
    def api(self, args):
        data = yaml.load(File(args.config).read_all())
Exemplo n.º 7
0
 def __init__(self, raise_exceptions=False, logger=None):
     self.raise_exceptions = raise_exceptions
     self.logger = logger or getLoggerWithConsoleHandler()
Exemplo n.º 8
0
Arquivo: r53.py Projeto: cnuber/gitbot
from boto.route53.connection import Route53Connection
from boto.route53.record import ResourceRecordSets
from commando.util import getLoggerWithConsoleHandler

logger = getLoggerWithConsoleHandler('gitbot.lib.r53')

s3zones = {

    "us-east-1": "Z3AQBSTGFYJSTF",
    "us-west-2": "Z3BJ6K6RIION7M",
    "us-west-1": "Z2F56UZL2M1ACD",
    "eu-west-1": "Z1BKCTXD74EZPE",
    "ap-southeast-1": "Z3O0J2DXBE1FTB",
    "ap-southeast-2": "Z1WCIGYICN2BYD",
    "ap-northeast-1": "Z2M4EHUR26P7ZW",
    "sa-east-1": "Z7KQH4QJS55SO",
    "us-gov-west-1": "Z31GFT0UA1I2HV"

}

class Route(object):

    def __init__(self, zone_name, **kwargs):
        try:
            self.connection = Route53Connection(**kwargs)
        except:
            raise Exception(
                'Please setup AWS security credentials in your environment.'
                'Add this to your startup file or virtualenv activate script:'
                'AWS_ACCESS_KEY_ID=<your aws key>'
                'AWS_SECRET_ACCESS_KEY=<your aws secret>'