示例#1
0
def load_custom_settings(config):
    path = find_scrapydweb_settings_py(SCRAPYDWEB_SETTINGS_PY, os.getcwd())

    if path:
        config['SCRAPYDWEB_SETTINGS_PY_PATH'] = path
        print(STAR)
        printf("Overriding custom settings from %s" % path, warn=True)
        print(STAR)
        config.from_pyfile(path)
    else:
        try:
            os.remove(LAST_CHECK_UPDATE_PATH)
        except:
            pass

        try:
            copyfile(config['DEFAULT_SETTINGS_PY_PATH'],
                     config['SCRAPYDWEB_SETTINGS_PY_PATH'])
        except:
            sys.exit(
                "\n{alert}\nPlease copy the 'default_settings.py' file from the path above "
                "to current working directory,\nand rename it to '{file}'.\n"
                "Then add your SCRAPYD_SERVERS in the config file and restart scrapydweb.\n{alert}"
                .format(alert=ALERT, file=SCRAPYDWEB_SETTINGS_PY))
        else:
            sys.exit(
                "\n{alert}\nThe config file '{file}' has been copied to current working directory.\n"
                "Please add your SCRAPYD_SERVERS in the config file and restart scrapydweb.\n{alert}"
                .format(alert=ALERT, file=SCRAPYDWEB_SETTINGS_PY))
示例#2
0
def load_custom_config(config):
    global scrapydweb_settings_py_path

    path = find_scrapydweb_settings_py(SCRAPYDWEB_SETTINGS_PY, os.getcwd())

    print('*' * 100)
    if path:
        scrapydweb_settings_py_path = path
        printf("Overriding custom settings from %s" %
               scrapydweb_settings_py_path,
               warn=True)
        config.from_pyfile(scrapydweb_settings_py_path)
    else:
        try:
            os.remove(LAST_CHECK_UPDATE)
        except:
            pass

        try:
            copyfile(os.path.join(CWD, 'default_settings.py'),
                     scrapydweb_settings_py_path)
        except:
            sys.exit(
                "Please copy the 'default_settings.py' file from above path to current working directory,\n"
                "and rename it to '%s'.\n"
                "Then add your SCRAPYD_SERVERS in the file and restart scrapydweb."
                % SCRAPYDWEB_SETTINGS_PY)
        else:
            sys.exit(
                "The config file '%s' has been copied to current working directory.\n"
                "Please add your SCRAPYD_SERVERS in the file and restart scrapydweb."
                % SCRAPYDWEB_SETTINGS_PY)
示例#3
0
def load_custom_config(config):
    global scrapydweb_settings_py_path

    path = find_scrapydweb_settings_py(SCRAPYDWEB_SETTINGS_PY, os.getcwd())

    print('')
    if path:
        scrapydweb_settings_py_path = path
        printf("Overriding custom settings from %s" % scrapydweb_settings_py_path, warn=True)
        config.from_pyfile(scrapydweb_settings_py_path)
    else:
        try:
            copyfile(os.path.join(CWD, 'default_settings.py'), scrapydweb_settings_py_path)
            printf("The config file '%s' is copied to current working directory, "
                   "and you can custom settings in it" % SCRAPYDWEB_SETTINGS_PY, warn=True)
        except:
            sys.exit("!!! Please copy the file 'default_settings.py' from above path to current working directory, "
                     "and rename it to '%s' to custom settings" % SCRAPYDWEB_SETTINGS_PY)
    print('')
示例#4
0
def test_find_scrapydweb_settings_py():
    find_scrapydweb_settings_py(SCRAPYDWEB_SETTINGS_PY, os.getcwd())