Beispiel #1
0
def main():    
    if '-h' in sys.argv or '--help' in sys.argv:
        # Just show the help.
        parse_args(sys.argv[1:])
        sys.exit(0)

    signal.signal(signal.SIGINT, signal_handler)

    (user, password, source, target, email, count, client, every, custom_extensions) = parse_args(sys.argv[1:])

    make_integer_if_exists_else_none = lambda x: int(x) if x is not None else None

    every, count = map(make_integer_if_exists_else_none, [every, count])

    logger.info("I will parse your command. Let me recap what you want to do:")
    msg =  "\n\n- Watch for frames that drop in /home/%s/%s under the renderfarm location\n" % (user, source)

    if client is not None:
        msg += "- Upload the rendered frames to %s on your dropbox home\n" % target
    else:
        msg += "- Transfer the frames to /home/%s/%s under your local account\n" % (user, target)

    if email is not None:
        msg += "- To send an email to %s after %d frames have been dropped\n" % (email, count)

    if every is not None:
        msg += "- To check for new rendered frames every %d seconds\n" % every

    if len(custom_extensions):
        msg += "- Also to watch for %s files\n" % custom_extensions

    logger.info(msg)

    answer = raw_input("Did I get it right? (y/n) ")

    if answer in ['yes', 'y', 'Y', 'Yes', 'YES']:
        logger.info("GREAT! I will proceed")
    else:
        logger.error("Shit I'm sorry. I'll get you out of here. Bye.")
        sys.exit(0)

    if email and count:
        notify = (email, count)
    else:
        notify = None

    watcher = FarmWatcher(
        user,
        password,
        source,
        target,
        notify=notify,
        client=client,
        custom_extensions=custom_extensions
    )
    watcher.run(every)
Beispiel #2
0
def test_illegal_source():
    with pytest.raises(SystemExit):
        parse_args(['loc*al1/local11', 'remote1/remote11'])
Beispiel #3
0
def test_passing_extensions_with_spaces():
    with pytest.raises(SystemExit):
        parse_args(['foo/bar', 'foo/bar', '-t', 'png jpeg'])
Beispiel #4
0
def test_empty():
    with pytest.raises(SystemExit):
        args = parse_args([])
Beispiel #5
0
def test_source_and_target_ending_slash():
    with pytest.raises(SystemExit):
        parse_args(['local1/local11/', 'remote1/remote11/'])
Beispiel #6
0
def test_source_and_target_starting_slash():
    with pytest.raises(SystemExit):
        parse_args(['/local1/local11', '/remote1/remote11'])
Beispiel #7
0
def test_illegal_target():
    with pytest.raises(SystemExit):
        parse_args(['local1/local11', 'remote1/remot+e11'])