Пример #1
0
def main():
    """Main function"""
    script_name = os.path.basename(__file__)[:-3]
    parser = argparse.ArgumentParser(
        description="Remove directories of repositories that were zipped")
    parser.add_argument("-v", "--verbose", type=int, default=config.VERBOSE,
                        help="increase output verbosity")
    parser.add_argument("-i", "--interval", type=int, nargs=2,
                        default=config.REPOSITORY_INTERVAL,
                        help="id interval")
    parser.add_argument("-c", "--count", action='store_true',
                        help="count results")
    parser.add_argument('-r', '--reverse', action='store_true',
                        help='iterate in reverse order')
    parser.add_argument('--check', type=str, nargs='*',
                        default={'all', script_name, script_name + '.py'},
                        help='check name in .exit')
    args = parser.parse_args()
    config.VERBOSE = args.verbose
    status = None
    if not args.count:
        status = StatusLogger(script_name)
        status.report()

    with connect() as session, savepid():
        apply(
            session,
            status,
            args.count,
            args.interval,
            args.reverse,
            set(args.check)
        )
Пример #2
0
def main():
    """Main function"""
    with savepid():
        scripts = sys.argv[1:]

        result = []

        try:
            with mount_basedir():
                config.BASE_DIR.mkdir(parents=True, exist_ok=True)
            config.LOGS_DIR.mkdir(parents=True, exist_ok=True)

            indexes = [
                index for index, name in enumerate(scripts)
                if name == "--all" or config.Path(name).exists()
                or config.Path(name + ".py").exists()
            ]
            indexes.sort()
            indexes.append(None)
            it_indexes = iter(indexes)
            next(it_indexes)
            to_execute = {
                scripts[cur]: scripts[cur + 1:nex]
                for cur, nex in zip(indexes, it_indexes)
            }
            options_to_all = []
            if "--all" in to_execute:
                options_to_all = to_execute["--all"]
                del to_execute["--all"]

            if not to_execute:
                to_execute = {script: [] for script in ORDER}

            for script, args in to_execute.items():
                if check_exit({"all", "main", "main.py"}):
                    print("Found .exit file. Exiting")
                    return
                if script.endswith(".py"):
                    script = script[:-3]
                args = args + options_to_all
                status = execute_script(script, args)
                result.append("{} {} --> {}".format(script, " ".join(args),
                                                    status))
            print("done")
        finally:
            status = StatusLogger("main closed")
            status.report()
            if config.EMAIL_TO:
                yag = yagmail.SMTP(config.EMAIL_LOGIN,
                                   oauth2_file=str(config.OAUTH_FILE))
                yag.send(to=config.EMAIL_TO.split(";"),
                         subject="{} is idle".format(config.MACHINE),
                         contents="{} finished at {}\n\nScripts:\n".format(
                             config.MACHINE,
                             datetime.now().strftime("%Y%m%dT%H%M%S")) +
                         "\n".join(result))
Пример #3
0
def main():
    """Main function"""
    parser = argparse.ArgumentParser(description="Delete unlinked files")
    parser.add_argument("-c",
                        "--count",
                        action='store_true',
                        help="count results")

    args = parser.parse_args()

    with savepid():
        apply(args.count)
Пример #4
0
def main():
    """Main function"""
    script_name = os.path.basename(__file__)[:-3]
    parser = argparse.ArgumentParser(description="Clone deleted repositories")
    parser.add_argument("-v",
                        "--verbose",
                        type=int,
                        default=config.VERBOSE,
                        help="increase output verbosity")
    parser.add_argument("-e",
                        "--retry-errors",
                        action='store_true',
                        help="retry errors")
    parser.add_argument("-i",
                        "--interval",
                        type=int,
                        nargs=2,
                        default=config.REPOSITORY_INTERVAL,
                        help="id interval")
    parser.add_argument("-c",
                        "--count",
                        action='store_true',
                        help="count results")
    parser.add_argument("-d",
                        "--dry-run",
                        action='store_true',
                        help="discover repositories but do not clone")
    parser.add_argument("-l",
                        "--list",
                        action='store_true',
                        help="list repositories but do not clone nor discover")
    parser.add_argument('-r',
                        '--reverse',
                        action='store_true',
                        help='iterate in reverse order')
    parser.add_argument('--check',
                        type=str,
                        nargs='*',
                        default={'all', script_name, script_name + '.py'},
                        help='check name in .exit')
    args = parser.parse_args()
    config.VERBOSE = args.verbose
    status = None
    if not args.count:
        status = StatusLogger(script_name)
        status.report()

    with connect() as session, savepid():
        apply(session, status,
              0 if args.retry_errors else consts.R_FAILED_TO_CLONE,
              args.dry_run, args.list, args.count, args.interval, args.reverse,
              set(args.check))
Пример #5
0
def main():
    """Main function"""
    parser = argparse.ArgumentParser(
        description="Use github API to load repositories until an error")
    parser.add_argument("-v",
                        "--verbose",
                        type=int,
                        default=config.VERBOSE,
                        help="increase output verbosity")
    args = parser.parse_args()
    config.VERBOSE = args.verbose
    with savepid():
        github = Github(config.GITHUB_USERNAME, config.GITHUB_PASSWORD)
        querier = Querier(github)
        querier.search_repositories()
Пример #6
0
def main():
    """Main function"""
    script_name = os.path.basename(__file__)[:-3]
    parser = argparse.ArgumentParser(description='Execute repositories')
    parser.add_argument('-v',
                        '--verbose',
                        type=int,
                        default=config.VERBOSE,
                        help='increase output verbosity')
    parser.add_argument('-e',
                        '--retry-errors',
                        action='store_true',
                        help='retry errors')
    parser.add_argument('-i',
                        '--interval',
                        type=int,
                        nargs=2,
                        default=config.REPOSITORY_INTERVAL,
                        help='repository id interval')
    parser.add_argument('-c',
                        '--count',
                        action='store_true',
                        help='count results')
    parser.add_argument('-r',
                        '--reverse',
                        action='store_true',
                        help='iterate in reverse order')
    parser.add_argument('--check',
                        type=str,
                        nargs='*',
                        default={'all', script_name, script_name + '.py'},
                        help='check name in .exit')

    args = parser.parse_args()
    config.VERBOSE = args.verbose
    status = None
    if not args.count:
        status = StatusLogger(script_name)
        status.report()

    with connect() as session, savepid():
        apply(session, status, args.count, args.interval, args.reverse,
              set(args.check))
Пример #7
0
def main():
    """Main function"""
    with connect() as session, mount_basedir(), savepid():
        for rep in session.query(Repository):
            if not rep.path.exists() and not rep.zip_path.exists():
                print(rep)