Beispiel #1
0
def main():
    if len(sys.argv) < 2:
        print "usage:", sys.argv[0], "register/deamon"
        return

    if not os.path.exists("keys"):
        os.makedirs("keys")

    utils.setup_keys()

    if sys.argv[1] == "register":
        if len(sys.argv) != 5:
            print "usage:", sys.argv[
                0], "register asn comma_seperated_neighbors_list is_transient(True/False)"
        as_number = int(sys.argv[2])
        neighbours = sys.argv[3].split(",")
        transient_flag = True
        if sys.argv[3] == "False":
            transient_flag = False
        register(as_number, neighbours, transient_flag)
    elif sys.argv[1] == "daemon":
        configure.main()
        deploy_rules.main()
    else:
        print "unrecognized option", sys.argv[1]
Beispiel #2
0
def update_essentials_billing(host_id, bm_packages):

    if filter(lambda x: not is_billing_package(x.package.name), bm_packages):
        raise Exception(
            "Following packages without \"bm\" prefix, but installing as billing packages: {0} "
            .format(str(bm_packages)))

    uLogging.debug("Stopping billing.")
    stop_pba()

    uLogging.debug("Updating billing packages.")
    uPEM.update_packages_on_host(host_id, bm_packages)

    # # Reloading all modules from billingToolsPath TODO: Right way, function stop_pba() is a crutch.
    # modules_for_reload = filter(
    #     lambda x: x is not None and hasattr(x, "__file__") and billingToolsPath in x.__file__,
    #     sys.modules.values())
    # map(reload, modules_for_reload)

    sys.path.append(billingToolsPath)
    import pba
    import configure
    import configure_db
    sys.path.remove(billingToolsPath)

    uLogging_info = uLogging.info
    uLogging_debug = uLogging.debug
    uLogging_log = uLogging.log

    # Disable a lot of messages during billing update
    uLogging.debug = uLogging.log_func(None, uLogging.DEBUG)
    uLogging.info = uLogging.log_func(None, uLogging.INFO)
    uLogging.log = uLogging.log_func(None, None)

    uLogging_info("Starting configure billing. ")
    (configure_db.o,
     configure_db.args) = configure_db.getOptions(['--unattended', '--ppab'])
    configure_db.main(configure_db.o, configure_db.args)
    uLogging_info("BSS DB configuration has been successfully completed.")
    (configure.o, configure.args) = configure.getOptions(['--unattended'])
    configure.main(configure.o, configure.args)
    uLogging_info(
        "BSS Application configuration has been sucessfully completed.")
    uUtil.execCommand(['sh', '/usr/local/bm/templatestore/tools/configure.sh'])
    uLogging_info("BSS Store configuration has been successfully completed.")
    uLogging_info("Billing configuration has been successfully completed.")

    uLogging_debug("Starting billing.")
    pba.start()()

    # restoring uLogging.* functions
    uLogging.debug = uLogging_debug
    uLogging.info = uLogging_info
    uLogging.log = uLogging_log
def get_configuration():
    if not os.path.isfile(configure.CONFIG_FILENAME):
        print 'The sender is not configured. Please enter the information below:'
        configure.main()

    with open(configure.CONFIG_FILENAME, 'r') as config_file:
        content = config_file.read()
        marker_pos = content.find('\0')
        api_key = content[:marker_pos]
        sender_id = content[marker_pos + 1:]

    return api_key, sender_id
Beispiel #4
0
    def __getattr__(self, name):
        if name not in self._deps:
            raise ValueError(
                "Project manifest does not list dependency {name}".format(
                    name=name))

        import confu.globals
        if name in confu.globals.deps:
            return confu.globals.deps[name]

        logger.info("configuring dependency {name}".format(name=name))

        import confu.recipes
        dep_dir = os.path.join(self._deps_dir, name)
        if os.path.isfile(os.path.join(dep_dir, "configure.py")):
            import sys
            sys.path.insert(0, dep_dir)
            try:
                import configure

                if sys.version_info >= (3, 4):
                    from importlib import reload  # Python 3.4+
                elif sys.version_info >= (3, 0):
                    from imp import reload  # Python 3.0 - 3.3
                else:
                    global reload

                reload(configure)
                config = configure.main(["--target", self._target])
                config.modules._sealed = True
                confu.globals.deps[name] = config.modules
                return config.modules
            finally:
                sys.path = sys.path[1:]
        elif name in confu.recipes.__dict__:
            configure = confu.recipes.__dict__[name]
            config = configure.main(["--target", self._target],
                                    root_dir=dep_dir)
            config.modules._sealed = True
            confu.globals.deps[name] = config.modules
            return config.modules
        else:
            logger.fatal(
                "don't know how to build {name}: configure.py not found in {path}"
                .format(name=name, path=dep_dir))

            import errno
            raise IOError(errno.ENOENT, os.strerror(errno.ENOENT),
                          os.path.join(dep_dir, "configure.py"))
Beispiel #5
0
def main():
    """ Game Menu """

    print_open_msg()
    controler = True

    while controler:
        option = int(
            input(
                "\nDigite:\n(1) Jogar\n(2) Adicionar Palavras\nQual é a sua escolha:"
            ))
        if option == 1:
            hangman.main()
            controler = False
        elif option == 2:
            configure.main()
            controler = False
        else:
            print("\n\n Erro: Escolha (1) Jogar ou (2) Adicionar Palavras\n")
Beispiel #6
0
def main():
    if len(sys.argv) < 2:
        print "usage:", sys.argv[0], "register/deamon"
        return

    if not os.path.exists("keys"):
            os.makedirs("keys")

    utils.setup_keys()

    if sys.argv[1] == "register":
        if len(sys.argv) != 5:
            print "usage:", sys.argv[0], "register asn comma_seperated_neighbors_list is_transient(True/False)"
        as_number = int(sys.argv[2])
        neighbours = sys.argv[3].split(",")
        transient_flag = True
        if sys.argv[3] == "False":
            transient_flag = False
        register(as_number, neighbours, transient_flag)
    elif sys.argv[1] == "daemon":
        configure.main()
        deploy_rules.main()
    else:
        print "unrecognized option", sys.argv[1]
Beispiel #7
0
def finish_config():
    # Converge
    returncode = configure.main(sys.argv)
    sys.exit(returncode)
def finish_config():
    # Converge
    returncode = configure.main(sys.argv)
    sys.exit(returncode)
                    config[modName] = bool(int(active))

        os.chdir('..')
        return config

def compileModule(config) :
    os.chdir('sip')
    for module,active in config.iteritems():
        if active:
            os.chdir(module)
            os.system('nmake')
            os.chdir('..')
    os.chdir('..')
    
if __name__ == '__main__':
    parser = OptionParser()
    parser.add_option("--config",
                      action="store_true",dest="config_flag",default=False,
                      help = 'Configure sip modules')
    (options,args) = parser.parse_args()
    if options.config_flag:
        sys.path.insert(0,'sip')
        import configure
        os.chdir('sip')
        configure.main()
        os.chdir('..')
        sys.path.pop(0)
    else:
        config = getModuleConfig()
        compileModule(config)
Beispiel #10
0
    def bison(cmd):
        os.system('bison ' + cmd)


if not 'build' in sys.argv:
    # usage
    print 'use "python setup.py build" to build SIP'
else:
    # TODO: submit a distutils.sysconfig patch to python.org
    print 'Generating parser.c from parser.y...'
    cwd = os.getcwd()
    try:
        os.chdir('sipgen')
        bison('parser.y -o parser.c')
    finally:
        os.chdir(cwd)

    # configures SIP to build locally
    import configure
    args = 'configure.py -b sipgen -d siplib -e siplib -v siplib'.split()
    DEBUG = os.path.splitext(sys.executable)[0].endswith('_d')

    if DEBUG: args.append('-u')

    configure.main(args)

    # do a complete clean build
    os.system('nmake clean')
    if not os.system('nmake'):
        print '*' * 80, '\nsuccess\n', '*' * 80
Beispiel #11
0
        return config
    except IOError:
        print 'You should Read the README_WINDOW First'
        raise

def compileModule(config) :
    os.chdir('sip')
    for module,active in config.iteritems():
        if active:
            os.chdir(module)
            os.system('nmake')
            os.chdir('..')
    os.chdir('..')
    
if __name__ == '__main__':
    parser = OptionParser()
    parser.add_option("--config",
                      action="store_true",dest="config_flag",default=False,
                      help = 'Configure sip modules')
    (options,args) = parser.parse_args()
    if options.config_flag:
        sys.path.insert(0,'sip')
        import configure
        os.chdir('sip')
        configure.main()
        os.chdir('..')
        sys.path.pop(0)
    else:
        config = getModuleConfig()
        compileModule(config)
Beispiel #12
0
else:
    def bison(cmd):
        os.system('bison ' + cmd)

if not 'build' in sys.argv:
    # usage
    print 'use "python setup.py build" to build SIP'
else:
    # TODO: submit a distutils.sysconfig patch to python.org
    print 'Generating parser.c from parser.y...'
    cwd = os.getcwd()
    try:
        os.chdir('sipgen')
        bison('parser.y -o parser.c')
    finally:
        os.chdir(cwd)
    
    # configures SIP to build locally
    import configure
    args = 'configure.py -b sipgen -d siplib -e siplib -v siplib'.split()
    DEBUG = os.path.splitext(sys.executable)[0].endswith('_d')

    if DEBUG: args.append('-u')

    configure.main(args)

    # do a complete clean build
    os.system('nmake clean')
    if not os.system('nmake'):
        print '*'*80, '\nsuccess\n', '*'*80
Beispiel #13
0
def main():
    parser.add_argument(
        '-v',
        '--version',
        action='version',
        version=__version__,
    )

    parser.add_argument('-c',
                        '--configure',
                        action='store_true',
                        dest='configure_requeriments',
                        help='Instalar dependências deste programa.')

    parser.add_argument('--clean',
                        action='store_true',
                        dest='clean_cache',
                        help='Apaga todos os arquivos baixados em cache.')

    parser.add_argument('-f',
                        '--info',
                        action='store',
                        nargs=1,
                        dest='pkg_info',
                        help='Mostra informações sobre um pacote')

    parser.add_argument('-l',
                        '--list',
                        action='store',
                        nargs=1,
                        dest='list_info',
                        help='Use --list apps ou --list installed')

    parser.add_argument('-i',
                        '--install',
                        action='store',
                        nargs='*',
                        dest='pkg_for_install',
                        type=str,
                        help='Instalar um pacote')

    parser.add_argument('-r',
                        '--remove',
                        nargs='*',
                        action='store',
                        dest='pkg_for_remove',
                        type=str,
                        help='Desisntala um pacote')

    parser.add_argument('-d',
                        '--downloadonly',
                        action='store_true',
                        dest='download_only',
                        help='Apenas baixa os pacotes sem instalar.')

    parser.add_argument('-y',
                        '--yes',
                        action='store_true',
                        dest='assumeyes',
                        help='Assume sim para indagações.')

    parser.add_argument('--download',
                        action='store',
                        dest='pkg_for_download',
                        type=str,
                        help='Somente baixa um pacote')

    parser.add_argument(
        '-u',
        '--self-update',
        action='store_true',
        dest='self_update',
        help='Instalar a versão mais recente deste programa apartir do github.'
    )

    args = parser.parse_args()
    if args.assumeyes:
        manager.assume_yes = True
    if args.clean_cache:
        from utils import appname, question
        from user_utils.commands import CommandsUtils
        from user_utils.userconf import ConfigAppDirs
        cfg = ConfigAppDirs(appname)
        cmds = CommandsUtils()
        files = os.listdir(cfg.get_dir_downloads())
        if bool(question(
                f'Deseja apagar {len(files)} arquivo(s) em cache')) == False:
            sys.exit(0)
        for file in files:
            path_file = os.path.join(cfg.get_dir_downloads(), file)
            print('Apagando ...', path_file)
            cmds.rmdir(path_file)

    if args.list_info:
        if args.list_info[0] == 'apps':
            manager.list_apps()
        elif args.list_info[0] == 'installed':
            manager.list_installed()
        elif args.list_info[0] == 'categories':
            manager.list_categories()
        else:
            print('ERRO')
            sys.exit(1)

    elif args.configure_requeriments:
        import configure
        configure.main()
    elif args.pkg_info:
        if not args.pkg_info[0] in obj_programs.keys():
            print(f'ERRO ... programa indisponível {args.pkg_info[0]}',
                  end=' ')
            print(
                'Use "--list apps" para listar todos os aplicativos disponíveis'
            )
            sys.exit(1)
        app = obj_programs[args.pkg_info[0]]
        manager.info(app)
    elif args.pkg_for_install:
        if args.download_only:
            # Criar lista de objetos para baixar.
            _list = []
            for key in args.pkg_for_install:
                if not key in manager.apps.keys():
                    print(f'ERRO programa indisponível ... {key}')
                    continue

                app = manager.apps[key]
                _list.append(app)
            manager.download_pkg(_list)
            return
        manager.install(args.pkg_for_install)

    elif args.pkg_for_remove:
        manager.uninstall(args.pkg_for_remove)
Beispiel #14
0
from configure import main

main()