Beispiel #1
0
  def main(self, suppress_warning=False):
    """Command line argument parser.

    This method will be removed in a future version (using the `azkaban`
    executable is now the preferred way of running the CLI).

    """
    from sys import argv
    from .__main__ import main
    import warnings
    script = argv[0]
    argv.insert(1, self.name)
    msg = """

      Use azkaban executable instead of running module directly:

        $ azkaban %s%s

      This current method leads to inconsistent error handling and will be
      disabled in a future release.
    """ % (
      ' '.join(argv[1:]),
      '' if argv[2] == 'run' or script == 'jobs.py' else ' -s %s' % (script, ),
    )
    if not suppress_warning:
      warnings.simplefilter('default')
    warnings.warn(msg, DeprecationWarning)
    main(self)
Beispiel #2
0
  def main(self):
    """Command line argument parser."""
    argv.insert(0, 'FILE')
    args = docopt(__doc__, version=__version__)
    if not args['--quiet']:
      logger.setLevel(logging.DEBUG)
      logger.addHandler(get_formatted_stream_handler())
    try:
      if args['build']:
        self.build(args['PATH'],
          environment=args['--environment'],
          force=args['--force'],
          )
      elif args['upload']:
        self.upload(
          environment=args['--environment'],
          url=args['URL'],
          user=args['--user'],
          alias=args['--alias'],
        )
      elif args['view']:
        job_name = args['JOB']
        if job_name in self._jobs:
          job = self._jobs[job_name]
          pretty_print(job.build_options)
        else:
          raise AzkabanError('missing job %r' % (job_name, ))
      elif args['list']:
        proj = defaultdict(list)
        formatted_name = ''
        for name, job in self._jobs.items():
          job_type = job.build_options.get('type', '--')
          job_deps = job.build_options.get('dependencies', '')
          job_path = job.build_options.get('path', '')
          formatted_name = format_archive_path(name,job_path)
          if job_deps:
            info = '%s [%s]' % (formatted_name, job_deps)
          else:
            info = formatted_name
          proj[job_type].append(info)
        # now list files
        if len(self._files.items()) > 0: 
          proj["file"] = []
        else:
          proj["file"] = None

        for fpath, apath in self._files.items():
          file_formatted_name = format_archive_path(fpath, apath)
          logger.debug(file_formatted_name)
          proj["file"].append(file_formatted_name)

        pretty_print(proj)
    except AzkabanError as err:
      logger.error(err)
      exit(1)
Beispiel #3
0
def run():
    """Do the thing"""
    if getuid() != 0:
        print("setup_img.py is not running as root. Would you like to exit now, or elevate to root here?")
        choice = input("exit or elevate: ").lower()
        if choice == "elevate":
            argv.insert(0, "sudo")
            leave(check_call(argv))
        else:
            print("Exiting . . .")
            leave(0)
    try:
        config = download_config()
    except:
        eprint("Your internet is either slow or non-existant. Internet is necessary for setup. Please try again later.")
        leave(2)
    setup(config)
Beispiel #4
0
def set_default_subparser(self, name, args=None, positional_args=0):
    """Set default subparser to interpreter"""
    ####################################################################
    subparser_found = False
    for arg in argv[1:]:
        if arg in ['-h', '--help']:
            break
    else:
        # pylint: disable=protected-access
        # disabling protected access because subparsers are protected
        # and we want to be able to have a default subparser
        for action in self._subparsers._actions:
            if not isinstance(action, _SubParsersAction):
                continue
            for _ in argv[1:]:
                subparser_found = True
        if not subparser_found:
            if args is None:
                argv.insert(len(argv) - positional_args, name)
            else:
                args.insert(len(args) - positional_args, name)
Beispiel #5
0
if platform == "darwin":
    # add mac specific options
    options = {
        'includes': ['pygame'],
        'resources': [
            'resources',
        ],
        'argv_emulation': True,
        'iconfile': 'resources/icon.icns',
        'semi_standalone': False,
    }
    if using_simplejson:
        options['includes'].insert(0, 'simplejson')

    # force the py2app build
    argv.insert(1, "py2app")

    # setup for mac .app (does the actual build)
    setup(
        setup_requires=['py2app'],
        app=[app + ".py"],
        options={'py2app': options},
    )
elif platform == "win32":
    import py2exe
    import pygame
    import glob
    import sys

    # hack to patch in win32com support
    # http://www.py2exe.org/index.cgi/win32com.shell
Beispiel #6
0
from bs4 import BeautifulSoup
import requests
from sys import argv
import re

default_movie = "http://www.imdb.com/title/tt0441773/fullcredits"
# Default url if none is provided

if len(argv) == 1:
    url = default_movie
elif argv[1].startswith("http://www.imdb.com/"):
    movie_id = re.sub("\D", "", argv[1])
    url = "http://www.imdb.com/title/tt" + movie_id[:7] + "fullcredits"
else:
    argv.insert(1, default_movie)
    url = default_movie


if len(argv) < 3:
    names_to_search = ("Matt", "Matthew", "Matti", "Matty", "Mat", "Mathew")
    # Default names to search if none is provided
else:
    names_to_search = tuple([str(i.lower().capitalize()) for i in argv[2:]])
    # Add names as command line arguments to override default names to search

r = requests.get(url)
soup = BeautifulSoup(r.text)
links = soup.find_all("a")

movie_title = soup.find("a", class_="subnav_heading").string
Beispiel #7
0
def do_open( client, changelist, files ):
        result = SUCCESS
        fs = []
        for file in files:
                fs.append( '\"' + file + '\"' )
        while fs:
                argv = fs[:BATCH_LIMIT]
                fs = fs[BATCH_LIMIT:]
                argv.insert( 0, repr( changelist ) )
                argv.insert( 0, "-c" )
                argv.insert( 0, "reopen" )
                argv.insert( 0, client )
                argv.insert( 0, "-c" )
                argv.insert( 0, QUOTED_P4_PATH )
                if do_command( argv ) != SUCCESS:
                        result = FAILURE
        return result
Beispiel #8
0
from bs4 import BeautifulSoup
import requests
from sys import argv
import re

default_movie = 'http://www.imdb.com/title/tt0441773/fullcredits'
#Default url if none is provided

if len(argv) == 1:
    url = default_movie
elif argv[1].startswith("http://www.imdb.com/"):
    movie_id = re.sub('\D', '', argv[1])
    url = 'http://www.imdb.com/title/tt' + movie_id[:7] + 'fullcredits'
else:
    argv.insert(1, default_movie)
    url = default_movie

if len(argv) < 3:
    names_to_search = ('Matt', 'Matthew', 'Matti', 'Matty', 'Mat', 'Mathew')
    #Default names to search if none is provided
else:
    names_to_search = tuple([str(i.lower().capitalize()) for i in argv[2:]])
    #Add names as command line arguments to override default names to search

r = requests.get(url)
soup = BeautifulSoup(r.text)
links = soup.find_all('a')

movie_title = soup.find('a', class_='subnav_heading').string
Beispiel #9
0
import telnetlib as T;from sys import argv as A;A[0]='localhost';A.insert(3,A[1]);T.Telnet(A[0],25).write("HELO %s\nMAIL FROM: %s\nRCPT TO: %s\nDATA\nFrom: %s\nSubject: %s\n%s\n.\n"%(tuple(A)))

#import smtplib as L;from sys import argv as A;L.SMTP('localhost','25').sendmail(A[1],A[2],'From<%s>\nTo<%s>\nSbuject:%s\n\n%s'%tuple(A[1:5]))

Beispiel #10
0
#! /usr/bin/env python

from distutils.core import setup, Extension, Command
import numpy
from sys import argv

if argv[1] == "build":
    argv[1] = "build_ext"
if argv[1] == "build_ext":
    argv.insert(2, "--swig-opts=-c++")

class clean(Command):
    """Cleans *.pyc and debian trashs, so you should get the same copy as 
    is in the svn.
    """
    
    description = "Clean everything"
    user_options = [("all","a","the same")]  

    def initialize_options(self):  
        self.all = None
    
    def finalize_options(self):   
        pass

    def run(self):
        import os
        os.system("py.cleanup")
        os.system("rm -f python-build-stamp-2.4")
        os.system("rm -f MANIFEST")
        os.system("rm -rf build")
Beispiel #11
0
#!/usr/bin/env python
import warnings
with warnings.catch_warnings():
    warnings.filterwarnings("ignore", category=DeprecationWarning)
    from pyflakes.scripts.pyflakes import main
try:
    main()
except SystemExit, e:
    pass

from sys import argv
argv.insert(1, '--repeat')
with warnings.catch_warnings():
    warnings.filterwarnings("ignore", category=ImportWarning)
    from pkg_resources import load_entry_point
load_entry_point('pep8', 'console_scripts', 'pep8')()

raise e
Beispiel #12
0
if len(argv) < 2 or not argv[1] in COMMANDS:
    printUsageAndAbort()

del argv[0]
command = argv[0]
del argv[0]

if command == "check":
    if path.isfile(SVN_PATH):
        print '.svn\n1'
        exit(SUCCESS)
    print 'Cannot find ', SVN_PATH
    exit(FAILURE)
elif command == "addfolder":
    del argv[0]  # the message
    argv.insert(0, "-N")
    argv.insert(0, "add")
elif command == "addfile":
    argv.insert(0, "add")
elif command == "addbinaryfile":
    argv.insert(0, "add")
elif command == "removefile":
    argv.insert(0, "remove")
elif command == "commitfile":
    exit(execv(batchCommit(argv), []))
elif command == "updatefile":
    argv.insert(0, "update")
elif command == "editfile":
    exit(SUCCESS)
elif command == "revertfile":
    argv.insert(0, "revert")
Beispiel #13
0
To build and install swiginac, type:
python setup.py build
python setup.py install

To check your installation, change directory to ./tests, and run 
python checkall.py

Ola Skavhaug
Ondrej Certik
"""

from  sys import argv
print argv
if argv[1] == 'build':
    argv[1] = 'build_ext'
    argv.insert(2,'--swig-cpp')


e = Extension(name='_swiginac', 
              sources=['swiginac.i'],
              include_dirs=['/usr/include/ginac'],
              library_dirs=['/usr/lib'],
              libraries=['ginac'],
              )

setup(name='swiginac',
    version='0.1',
    description='swiginac extention module',
    author='Ola Skavhaug',
    author_email='*****@*****.**',
    url='http://swiginac.berlios.de/',
#!/usr/bin/env python
from sys import argv
from subprocess import Popen

command = argv.pop(0)

print("Running {} command...".format(command))
cmd = "/bin/" + command
argv.insert(0, cmd)
p = Popen(argv)
ret = p.wait()
print("Command completed with ret = {}".format(ret))


if len( argv ) < 2 or not argv[1] in COMMANDS:
	printUsageAndAbort()

del argv[0]
command = argv[0]
del argv[0]

if command == "check":
	if path.isfile( CVS_PATH ):
		print 'CVS\n0'
		exit(SUCCESS)
	print 'Cannot find ', CVS_PATH
	exit(FAILURE)
elif command == "addfolder":
	del argv[0] # the message
	argv.insert( 0, "add" )
elif command == "addfile":
	argv.insert( 0, "add" )
elif command == "addbinaryfile":
	argv.insert( 0, "-kb" )
	argv.insert( 0, "add" )
elif command == "removefile":
	argv.insert( 0, "remove" )
elif command == "commitfile":
	exit( execv( batchCommit( argv ), [] ) )
elif command == "updatefile":
	argv.insert( 0, "-d" )
	argv.insert( 0, "-C" )
	argv.insert( 0, "update" )
elif command == "updatefolder":
	argv.insert( 0, "-d" )
Beispiel #16
0
if len(argv) < 2 or not argv[1] in COMMANDS:
    printUsageAndAbort()

del argv[0]
command = argv[0]
del argv[0]

if command == "check":
    if path.isfile(CVS_PATH):
        print 'CVS\n0'
        exit(SUCCESS)
    print 'Cannot find ', CVS_PATH
    exit(FAILURE)
elif command == "addfolder":
    del argv[0]  # the message
    argv.insert(0, "add")
elif command == "addfile":
    argv.insert(0, "add")
elif command == "addbinaryfile":
    argv.insert(0, "-kb")
    argv.insert(0, "add")
elif command == "removefile":
    argv.insert(0, "remove")
elif command == "commitfile":
    exit(execv(batchCommit(argv), []))
elif command == "updatefile":
    argv.insert(0, "-d")
    argv.insert(0, "-C")
    argv.insert(0, "update")
elif command == "updatefolder":
    argv.insert(0, "-d")
Beispiel #17
0
#!/usr/bin/env python3

# Import Modules
from sys import (argv as sysArgv, stdin, stdout, stderr)

def main(argv=None) :
	'''main(): Main function.
	Arguments:
	  argv : List of command line arguments.
	'''
	...

if __name__ == "__main__" :
	sysArgv.insert(0, "--scripted")  # Called as standalone script
	main(sysArgv)
Beispiel #18
0
You should have received a copy of the GNU General Public License
along with The Python Image Manipulation Project.  If not, see
<http://www.gnu.org/licenses/>.
"""

from distutils.core import setup, Extension
import os
from sys import argv
from glob import glob

# change to the directory this setup file is in
os.chdir( os.path.abspath( os.path.dirname( argv[ 0 ] ) ) )

if not ( 'build' in argv ):
    argv.insert( 1, 'build' )


INCLUDE = [ ]

compiled_plugins =  [
                        'histogramEq',
                        'invert',
                    ]


compiled_libs    =  [
                        'cCore',
                        'color',
                        'nintendize',
                        'medianFilter',
Beispiel #19
0
# mac osx
if platform == "darwin":
	# add mac specific options
	options = {
		'includes': ['pygame'],
		'resources': ['resources',],
		'argv_emulation': True,
		'iconfile': 'resources/icon.icns',
		'semi_standalone': False,
	}
	if using_simplejson:
		options['includes'].insert(0, 'simplejson')
	
	# force the py2app build
	argv.insert(1, "py2app")
	
	# setup for mac .app (does the actual build)
	setup(
		setup_requires=['py2app'],
		app=[app + ".py"],
		options={'py2app': options},
	)
elif platform == "win32":
	import py2exe
	import pygame
	import glob
	import sys
	
	# hack to patch in win32com support
	# http://www.py2exe.org/index.cgi/win32com.shell
if len( argv ) < 2 or not argv[1] in COMMANDS:
	printUsageAndAbort()

del argv[0]
command = argv[0]
del argv[0]

if command == "check":
	if path.isfile( SVN_PATH ):
		print '.svn\n1'
		exit(SUCCESS)
	print 'Cannot find ', SVN_PATH
	exit(FAILURE)
elif command == "addfolder":
	del argv[0] # the message
	argv.insert( 0, "-N" )
	argv.insert( 0, "add" )
elif command == "addfile":
	argv.insert( 0, "add" )
elif command == "addbinaryfile":
	argv.insert( 0, "add" )
elif command == "removefile":
	argv.insert( 0, "remove" )
elif command == "commitfile":
	exit( execv( batchCommit( argv ), [] ) )
elif command == "updatefile":
	argv.insert( 0, "update" )
elif command == "editfile":
	exit(SUCCESS)
elif command == "revertfile":
	argv.insert( 0, "revert" )
Beispiel #21
0
        del argv[0]

        if command == "check":
                if path.isfile( P4_PATH ):
                        print '\n0'
                        exit(SUCCESS)
                print 'Cannot find ', P4_PATH
		exit(FAILURE)
        client = get_current_client()
        if client == None:
                print get_current_directory(), "is not in any p4 clients\n"
                exit( FAILURE )
        if command == "addfolder":
                exit(SUCCESS)  # adding folder is not supported in p4
        elif command == "addfile":
                argv.insert( 0, "add" )
        elif command == "addbinaryfile":
                argv.insert( 0, "add" )
        elif command == "removefile":
                argv.insert( 0, "revert" )
                argv.insert( 0, client[0] )
                argv.insert( 0, "-c" )
                argv.insert( 0, QUOTED_P4_PATH )
                do_command( argv )
                del argv[0]
                del argv[0]
                del argv[0]
                del argv[0]
                argv.insert( 0, "delete" )
        elif command == "commitfile":
                exit( do_submit( argv ) )
Beispiel #22
0
    for token in output.split():
        if token[:2] != "-W":
            kw.setdefault(flag_map.get(token[:2]), []).append(token[2:])
    return kw

os.chdir(pjoin("src", "swiginac"))

# The command line argument for running swig in c++ mode has changed from
# Python 2.3 to 2.4. We support both.
swig_opt = '--swig-cpp'
if distutils.__version__ >= '2.4': swig_opt = '--swig-opts=-c++'

if argv[1] == 'build':
    argv[1] = 'build_ext'
if argv[1] == 'build_ext':
    argv.insert(2, swig_opt)
    
e = Extension(name='_swiginac',
              sources=['swiginac.i'],
              **pkgconfig("ginac")
             )

setup(name='swiginac',
    version='1.5.1.1',
    description='interface to GiNaC, providing Python with symbolic mathematics',
    author='Ola Skavhaug',
    author_email='*****@*****.**',
    url='http://swiginac.berlios.de/',
    ext_modules=[e],
    py_modules= ['swiginac'],
    )
Beispiel #23
0
    kill_process()
    start_process()


def start_watch(path, callback):
    observer = Observer()
    observer.schedule(MyFileSystemEventHandler(restart_process),
                      path,
                      recursive=True)
    observer.start()
    log('Watching directory %s...' % path)
    start_process()

    try:
        while True:
            time.sleep(0.5)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()


if __name__ == '__main__':
    argv = sys.argv[1:]
    if not argv:
        print('Usage: ./pymonitor your-script.py')
        exit(0)
    if argv[0] != 'python':
        argv.insert(0, 'python')
    command = argv
    path = os.path.abspath('.')
    start_watch(path, None)