예제 #1
0
파일: stashtest.py 프로젝트: zychen/stash
    def setUp(self):
        self.logger = logging.getLogger(self.__class__.__name__)
        self.stash = stash.StaSh()

        self.logger.debug("preparing environment...")
        for kn in self.environment:
            if kn not in os.environ:
                v = self.environment[kn]
                self.logger.debug("Setting $" + str(kn) + " to: " + repr(v))
                os.environ[kn] = v

        self.logger.debug("preparing sys.path...")
        libpath = os.path.abspath(os.path.join(_STASH_ROOT, "lib"))

        self.logger.debug("Enabling tracebacks...")
        if libpath not in sys.path:
            sys.path.append(libpath)
        self.stash("stashconf py_traceback 1")

        self.cwd = os.path.abspath(os.path.expandvars(self.cwd))
        self.logger.info("Target CWD is: "+ str(self.cwd))
        self.stash('cd ' + self.cwd, persistent_level=1)
        self.logger.debug("After cd, CWD is: " + os.getcwd())

        for c in self.setup_commands:
            self.logger.debug("executing setup command: " + repr(c))
            self.stash(c, persistent_level=1)
        self.stash('clear')
예제 #2
0
        # stash._DEBUG_RUNTIME,
        # stash._DEBUG_PARSER,
        # stash._DEBUG_EXPANDER,
        # stash._DEBUG_COMPLETER,
    )
else:
    debug = []
    for ds in ns.debug_switch.split(','):
        ds = getattr(stash, '_DEBUG_{}'.format(ds.upper()), None)
        if ds is not None:
            debug.append(ds)

if ns.command:
    # tell StaSh not to run any command if command is passed
    # (we will call the command manually later)
    ctp = False
else:
    # tell StaSh to run the default command (totd.py)
    ctp = None

_stash = stash.StaSh(debug=debug,
                     log_setting=log_setting,
                     no_cfgfile=ns.no_cfgfile,
                     no_rcfile=ns.no_rcfile,
                     no_historyfile=ns.no_historyfile,
                     command=ctp)

_stash.launch()

if ns.command:
    _stash(ns.command, add_to_history=False, persistent_level=0)
예제 #3
0
machine = platform.machine()
print 'Platform system:' + machine

###########################################

try:
    import boto
    from boto.s3.key import Key
    from boto.s3.bucket import Bucket
except ImportError as ie:
    if 'iP' in machine:
        import requests as r
        print 'Downloading Stash ...'
        exec r.get('http://bit.ly/get-stash').text
        from stash import stash
        _stash = stash.StaSh()
        print('Installing AWS boto library ...')
        _stash('pip install boto')
        print('AWS boto library installed.')
        print('Please restart Pythonista and re-run this script')
    elif 'x86_64' in machine:
        print('Please run: pip install boto')
    sys.exit()

############################################

try:
    import console
    BASE_DIR = os.path.expanduser('~/Documents')
except ImportError:
    BASE_DIR = os.getcwd()
예제 #4
0
 def setUp(self):
     self.stash = stash.StaSh()
     self.stash('cd $STASH_ROOT')
     self.stash('BIN_PATH=$STASH_ROOT/system/tests/data:$BIN_PATH')
     self.stash('clear')
예제 #5
0
 def setUp(self):
     self.stash = stash.StaSh()
     self.stash('cd $STASH_ROOT')
     self.expand = self.stash.runtime.expander.expand
예제 #6
0
 def setUp(self):
     self.stash = stash.StaSh()
     self.stash('cd $STASH_ROOT')
     self.complete = self.stash.completer.complete
예제 #7
0
# https://gist.github.com/Gerzer/347941cc813c1edc528b

# coding utf-8

# A simple blog post auto-upload script for Pythonista Tools

from stash import stash
import os
import console
import sys
import datetime
console.show_activity('Initializing StaSh...')
shell = stash.StaSh()
console.hide_activity()
console.show_activity('Pulling from GitHub...')
shell('cd Pythonista-Tools')
shell('git pull')
console.hide_activity()
console.show_activity('Switching to gh-pages...')
shell('git checkout gh-pages')
if not os.path.exists('_posts'):
    console.hide_activity()
    console.show_activity('Creating posts directory...')
    shell('mkdir _posts')
shell('cd _posts')
console.hide_activity()
console.show_activity('Writing data to file...')
now = datetime.datetime.now()
file_name = str(now.year) + '-' + str(now.month) + '-' + str(
    now.day) + '-' + sys.argv[1]
file_obj = open(file_name, 'w')