Exemple #1
0
    subprocess.run(["mkdir", fullApiPath])

    subprocess.run(["cp", "Helpers.py", fullApiPath + "/Helpers.py"])
    subprocess.run(["cp", "MongoHelpers.py", fullApiPath + "/MongoHelpers.py"])
    subprocess.run([
        "cp", "jittlov_dependencies_template.py",
        fullApiPath + "/jittlov_dependencies.py"
    ])
    subprocess.run(
        ["cp", "jittlov_setup_template.py", fullApiPath + "/jittlov_setup.py"])

    Helpers.update_file(fullApiPath + "/jittlov_dependencies.py",
                        fullApiPath + "/jittlov_dependencies.py",
                        [{
                            "search": "[apiName]_venv",
                            "replace": apiName + "_venv"
                        }, {
                            "search": "#![filePath]/",
                            "replace": "#!" + filePath + '/'
                        }])

    Helpers.update_file(fullApiPath + "/jittlov_setup.py",
                        fullApiPath + "/jittlov_setup.py",
                        [{
                            "search": "[apiName]_venv",
                            "replace": apiName + "_venv"
                        }, {
                            "search": "#![filePath]/",
                            "replace": "#!" + filePath + '/'
                        }])
Exemple #2
0
api_path = sys.argv[1]
api_name = sys.argv[2]

fullApiPath = api_path + '/' + api_name

print("Copying API files into virtual environment.")
subprocess.run(["cp", "__init_template__.py", fullApiPath + "/__init__.py"])
subprocess.run(["cp", "MongoApi.py", fullApiPath])
subprocess.run(["cp", "MongoApiConfig.py", fullApiPath])
subprocess.run(["cp", "run_template.sh", api_path + "/run.sh"])
subprocess.run(["chmod", "+x", api_path + "/run.sh"])

print("Updating MongoApi file")
Helpers.update_file(fullApiPath + "/MongoApi.py", fullApiPath + "/MongoApi.py",
                    [{
                        "search": "[apiName]",
                        "replace": api_name
                    }])

print("Updating MongoApiConfig file")
databaseUrl = MongoHelpers.confirm_mongo_db()
databaseName = MongoHelpers.confirm_mongo_db_name(databaseUrl)
databaseTable = MongoHelpers.confirm_mongo_collection_name(
    databaseUrl, databaseName)

apiBroadcastIp = Helpers.confirm_choice(
    "Please enter the IP for the API to broadcast: [ex: 127.0.0.1] ")
apiBroadcastHttp = input("Do you want to use HTTPS? [y/n] ")

if apiBroadcastHttp == "Y" or apiBroadcastHttp == "y":
    apiBroadcastHttp = "https://"