Beispiel #1
0
from nacl.git import merge_single_repository
from nacl.git import remote_prune
from nacl.git import remote_diff
from nacl.git import compare_remote
from nacl.base import init_nacl
from vendor.docopt import docopt
import sys
# This is a BAD hack to avoid SSLContext Warnings of urllib3 in python <2.7.9
# See: https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning

if sys.version_info < (2, 7, 9):
    import logging
    logging.captureWarnings(True)

if __name__ == '__main__':
    arguments = docopt(__doc__, version='nacl-git version 0.1')
    # print(arguments)

# Before we do anything else, we check, if nacl will possibly work.
init_nacl()


# list all git repositories
if arguments['list'] or arguments['l']:
    list_salt_git_repositories()

if arguments['branch'] or arguments['b']:
    change_or_create_branch(arguments['BRANCH'])

if arguments['checkout'] or arguments['c']:
    checkout_branch(arguments['BRANCH'])
Beispiel #2
0
# -*- coding: utf-8 -*-

"""nacl-setup

Usage:
  nacl-setup.py git
  nacl-setup.py nacl
  nacl-setup.py (-h | --help)
  nacl-setup.py --version

Options:
  git               Setup your local git, e.g. name and email-adress
  nacl              Setup nacl itself (the .nacl.conf file)
  -h --help         Show this screen.
  --version         Show version.

"""
from nacl.setup import setup_git
from nacl.setup import setup_nacl
from vendor.docopt import docopt

if __name__ == "__main__":
    arguments = docopt(__doc__, version="nacl-setup version 0.1")
    # print(arguments)

if arguments["git"]:
    setup_git()

if arguments["nacl"]:
    setup_nacl()
Beispiel #3
0
def main(wf):
    """Run Script Filter.

    Args:
        wf (workflow.Workflow): Workflow object.

    Returns:
        int: Exit status.
    """
    args = docopt(__doc__, wf.args)

    log.debug('args : {!r}'.format(args))

    query = args.get('<query>')

    if args.get('--openhelp'):
        subprocess.call(['open', README_URL])
        return 0

    if args.get('--openunits'):
        path = wf.datafile(CUSTOM_DEFINITIONS_FILENAME)
        if not os.path.exists(path):
            shutil.copy(
                wf.workflowfile('{0}.sample'.format(
                                CUSTOM_DEFINITIONS_FILENAME)),
                path)

        subprocess.call(['open', path])
        return 0

    if args.get('--places'):
        value = int(query)
        log.debug('Setting `decimal_places` to {!r}'.format(value))
        wf.settings['decimal_places'] = value
        print('Set decimal places to {}'.format(value))
        # subprocess.call(['osascript', '-e', ALFRED_AS])
        return 0

    if not query or not query.strip():
        wf.add_item('View Help File',
                    'Open help file in your browser',
                    valid=True,
                    arg='--openhelp',
                    icon=ICON_HELP)

        wf.add_item('View Supported Currencies',
                    'View and search list of supported currencies',
                    autocomplete=' currencies {0} '.format(DELIMITER),
                    icon=ICON_CURRENCY)

        wf.add_item(('Decimal Places in Results '
                    '(current : {0})'.format(wf.settings.get(
                                            'decimal_places',
                                            DECIMAL_PLACES_DEFAULT))),
                    'View and search list of supported currencies',
                    autocomplete=' places {0} '.format(DELIMITER),
                    icon=ICON_SETTINGS)

        wf.add_item('Edit Custom Units',
                    'Add and edit your own custom units',
                    valid=True,
                    arg='--openunits',
                    icon='icon.png')

        wf.send_feedback()
        return 0

    else:  # Currencies or decimal places
        if query.endswith(DELIMITER):  # User deleted trailing space
            subprocess.call(['osascript', '-e', ALFRED_AS])
            return 0

        mode, query = [s.strip() for s in query.split(DELIMITER)]

        if mode == 'currencies':

            currencies = sorted([(name, symbol) for (symbol, name)
                                in CURRENCIES.items()])

            if query:
                currencies = wf.filter(query, currencies,
                                       key=lambda t: ' '.join(t),
                                       match_on=MATCH_ALL ^ MATCH_ALLCHARS,
                                       min_score=30)

            else:  # Show last update time
                age = wf.cached_data_age(CURRENCY_CACHE_NAME)
                if age > 0:  # Exchange rates in cache
                    td = timedelta(seconds=age)
                    wf.add_item('Exchange rates updated {}'.format(
                                human_timedelta(td)),
                                icon=ICON_INFO)

            if not currencies:
                wf.add_item('No matching currencies',
                            'Try a different query',
                            icon=ICON_WARNING)

            for name, symbol in currencies:
                wf.add_item('{0} // {1}'.format(name, symbol),
                            'Use `{0}` in conversions'.format(symbol),
                            icon=ICON_CURRENCY)

            wf.send_feedback()

        elif mode == 'places':

            if query:
                if not query.isdigit():
                    wf.add_item('Invalid number : {0}'.format(query),
                                'Please enter a number',
                                icon=ICON_WARNING)
                else:
                    wf.add_item('Set decimal places to : {0}'.format(query),
                                'Hit `ENTER` to save',
                                valid=True,
                                arg='--places {0}'.format(query),
                                icon=ICON_SETTINGS)
            else:
                wf.add_item('Enter a number of decimal places',
                            'Current number is {0}'.format(
                                wf.settings.get('decimal_places',
                                                DECIMAL_PLACES_DEFAULT)),
                            icon=ICON_INFO)

            wf.send_feedback()
Beispiel #4
0
"""

from nacl.flow import NaclFlow
from nacl.base import init_nacl
from vendor.docopt import docopt
import sys
# This is a BAD hack to avoid SSLContext Warnings of urllib3 in python <2.7.9
# See: https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning

if sys.version_info < (2, 7, 9):
    import logging
    logging.captureWarnings(True)

if __name__ == '__main__':
    arguments = docopt(__doc__, version='nacl-flow version 0.1')
    # print(arguments)

# Before we do anything else, we check, if nacl will possibly work.
init_nacl()

if arguments['issues'] or arguments['i']:
    flow = NaclFlow()
    flow.get_all_issues(arguments['all'])

if arguments['my-issues'] or arguments['mi']:
    flow = NaclFlow()
    flow.get_my_issues(arguments['all'])

if arguments['close-issue'] or arguments['ci']:
    flow = NaclFlow()