Beispiel #1
0
def main():
	args = vars(parser.parse_args())
	filename = os.path.join(os.getcwd(), args["image"][0])

	image = skimage.img_as_uint(color.rgb2gray(io.imread(filename)))

	subsample = 1

	if (not args["subsample"] == 1):
		subsample = args["subsample"][0]

		image = transform.downscale_local_mean(image, (subsample, subsample))
		image = transform.pyramid_expand(image, subsample, 0, 0)

	image = exposure.rescale_intensity(image, out_range=(0,args["depth"][0]))

	if (args["visualize"]):
		io.imshow(image)
		io.show()

	source = generate_face(image, subsample, args["depth"][0], FLICKER_SPEED)

	if source:
		with open(args["output"][0], 'w') as file_:
			file_.write(source)
	else:
		print "Attempted to generate source code, failed."
Beispiel #2
0
def main(argv=sys.argv):

    argv = argv[1:]

    if len(argv) == 0:
        parser.parse_args(["-h"])
        sys.exit(0)

    args = parser.parse_args(argv)

    try:
        exit_code = time_add(args)
        sys.exit(exit_code)

    except Exception as e:
        error_type = type(e).__name__
        sys.stderr.write("{0}: {1}\n".format(error_type, e.message))
        sys.exit(1)
Beispiel #3
0
    def test_attrs(self):
        options = parser.parse_args([
            '--sx-url=url',
            '--access-log-path=path',
            '--upload-interval=60',
        ])

        assert options.sx_url == 'url'
        assert options.access_log_path == 'path'
        assert options.upload_interval == 60
Beispiel #4
0
def main(args=sys.argv[1:], env=Environment()):
    """Run the main program and write the output to ``env.stdout``.

    Return exit status code.

    """

    if env.config.default_options:
        args = env.config.default_options + args

    args = parser.parse_args(args=args, env=env)

    return 0
Beispiel #5
0
#!/usr/bin/env python3

import os
import sys
import png
import random

from cli import parser, query_yes_no
from colors import Colors
from core import Grid, Path, Node
from draw import Drawer

args = parser.parse_args()

# Show available colors
if args.colors:
    longest = max(list(Colors), key=lambda c: len(c.name))
    padding = len(longest.name) + 1
    print('Available colors:')
    for color in list(Colors):
        print(color.name.rjust(padding), color.value)
    exit(0)

# Configure map color
if args.color:
    try:
        color = Colors[args.color]
    except KeyError:
        parser.error(f'Color \'{args.color}\' doesn\'t exist. '
                     'Try --colors to see all the available colors.')
else:
Beispiel #6
0
 def test_fail(self):
     with pytest.raises(SystemExit):
         parser.parse_args([])
     with pytest.raises(SystemExit):
         parser.parse_args(['foo'])
Beispiel #7
0
    def test_defaults(self):
        options = parser.parse_args(['--sx-url=url'])

        assert options.access_log_path == DEFAULT_ACCESS_LOG_PATH
        assert options.upload_interval == DEFAULT_UPLOAD_INTERVAL
Beispiel #8
0
#!/usr/bin/env python
"""
The main entry point.
"""
import logging
from cli import parser, prompt_values
from core import logger, GitSnatch
from github import Github


if __name__ == '__main__':
    args = parser.parse_args()

    if args.verbose:
        logger.setLevel(logging.INFO)

    pyer = Github(args.repo)
    pyer.clone()
    pyer.load_properties()
    pyer.properties = prompt_values(pyer.properties)
    pyer.generate_in(args.dst)