def test_through(tmpdir): """ integration test load/read to os.environ """ tmpfile = tmpdir.join('env.bash') tmpfile.write('FOO=BAR') if 'FOO' in os.environ: del os.environ['FOO'] # pragma: no cover envbash.load_envbash(str(tmpfile)) assert os.environ['FOO'] == 'BAR'
def predictor_unit_test(pkg, exe, distro='eloquent', install_dir = '/home/ros/core_ws/install'): ret_val = 0 # set colcon prefix path load_envbash(install_dir + '/setup.bash', override=True) # set ros_run_cmd ros_run_cmd = '/opt/ros/%s/bin/ros2 run %s %s' distro = distro # run try: subprocess.check_output(ros_run_cmd%(distro, pkg, exe) , shell=True) except subprocess.CalledProcessError as exc: ret_val = exc.returncode return ret_val
def _checkup_and_load_env(): work_dir = os.getcwd() jobby_dir = os.path.join(work_dir, '.jobby') scratch_dir = os.path.join(jobby_dir, 'scratch') env_file = os.path.join(jobby_dir, '.env') if (not os.path.exists(jobby_dir)) \ or (not os.path.isdir(jobby_dir)): _fail('\'.jobby\' directory not found at \'%s\'.' % work_dir) load_envbash(env_file) os.environ['JOBBY_LIB_DIR'] = LIB_DIR os.environ['JOBBY_WORK_DIR'] = work_dir os.environ['JOBBY_SCRATCH_DIR'] = scratch_dir
def _load_config_file(cfg): return load_envbash(cfg)
#!/usr/bin/env python3 import envbash import ephem import time import sys import os from envbash import load_envbash # load bash environment vars load_envbash('/home/pi/.noaa-v2.conf') tz_offset = int(os.environ['TZ_OFFSET']) lat = str(os.environ['LAT']) lon = str(os.environ['LON']) timezone = tz_offset + time.localtime().tm_isdst date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(sys.argv[1])-(timezone*60*60))) obs=ephem.Observer() obs.lat = lat obs.long = lon obs.date = date sun = ephem.Sun(obs) sun.compute(obs) sun_angle = float(sun.alt) * 57.2957795 # Rad to deg print(int(sun_angle))
from envbash import load_envbash load_envbash("devel.env") if __name__ == "__main__": from main import app app.run(host="0.0.0.0", debug=True)
# check paths exist paths = [ args.seekdir, args.seekbin, args.known_good_results, args.outputdir ] for path in paths: if not os.path.exists(path): print('path {} does not exist'.format(path)) sys.exit(-1) seekMinerBin = os.path.join(args.seekbin, 'SeekMiner') goldStdDir = args.known_good_results bashEnvironmentFile = os.path.join(args.seekdir, 'seek_env') print('Load bash environment file {}'.format(bashEnvironmentFile)) load_envbash(bashEnvironmentFile) # The query files have the query strings to run (multiple queries per file # one query per line), located in goldStdDir filepattern = os.path.join(goldStdDir, r'*.query.txt') queryFiles = [queryfile for queryfile in glob.iglob(filepattern)] correlation_errors = 0 # Run SeekMiner for all query files for qfile in queryFiles: path, filename = os.path.split(qfile) # the first part of the query file name will be used for the result directory name queryName = filename.split('.')[0] resultDir = os.path.join(args.outputdir, queryName) utils.checkAndMakePath(resultDir) print('SeekMiner run query {}'.format(queryName))
# intializing the window from tab_bindings import * sys.path.append("$SPINE_DIR/") sys.path.append("$SPINE_DIR/reticulation/") # Color ttk via style # todo... fix_me ... create style.py and move any shits there style = ttk.Style() style.configure("Black.Tab", foreground="white", background="black") # Load wsl profile through envbash to get BASH Variables for current project title only # upon start-spine loading. # ... Project Title is then updated to statusbar through textvariable='userinput' and command at end of (process) function load_envbash('reticulation/gen_wordsmith_profile', remove=True) project_title = (os.environ['TITLE']) author_name = (os.environ['AUTHOR']) author_email = (os.environ['EMAIL']) wip_folder = (os.environ['WIP_DIR']) wip_root = (os.environ['WIP_ROOT']) ################### #Tab window contents i.e. buttons ######################### # 1st tab definitions, mostly buttons def openCheatSheet(): print ("Opening Sublime Text Cheat Sheet...") subprocess.Popen(['start-opencheatsheet'])
https://discordpy.readthedocs.io/en/latest/faq.html this page explains why await bot.process_commands(message) is necessary in on_message, and also explains how to make subcommands. """ from telnetlib import Telnet import re import requests import random from envbash import load_envbash import os import time from discord.ext import commands, tasks from discord.enums import Status load_envbash('env.txt') TOKEN = os.getenv('DISCORD_TOKEN') bot_channel_id = int(os.getenv('bot_channel_id')) owner_user_id = int(os.getenv('owner_user_id')) # GUILD = os.getenv('DISCORD_GUILD') # client = discord.Client() bot = commands.Bot(command_prefix='!') info_dir = os.path.join(os.path.dirname(__file__), 'info') async def get_owner(): try: return get_owner.owner except AttributeError:
import re import numpy as np import os import time from envbash import load_envbash # run the config variables set script from setuptools.command.test import test CONFIG_FILENAME = 'config' if not os.path.isfile('%s' % CONFIG_FILENAME): print('config file named \'%s\' not found' % CONFIG_FILENAME) exit(10) load_envbash(CONFIG_FILENAME) input_file_dir = os.environ['datafolder'] if not os.path.exists(input_file_dir): print('input_file_dir does not exist or is not configured: \'%s\'' % input_file_dir) exit(10) output_file_dir = os.environ['output_file_dir'] if not os.path.exists(output_file_dir): print('output_file_dir does not exist or is not configured: \'%s\'' % output_file_dir) exit(10) currency_pairs = os.environ['pairs'].split(" ")
shutil.copytree("module/tx-router", f"{build}/tx-router", dirs_exist_ok=True) shutil.copytree("plugin", f"{build}/tx-router/plugin", dirs_exist_ok=True) shutil.copy("test.system/env.pds", f"{build}/tx-router/env.txrouter") logger.info(f"setting env to {env}") os.environ.update(env) with open(f"{build}/tx-router/env.txrouter", "a") as f: f.write("\n") for k, v in env.items(): f.write(f"{k}={v}\n") shutil.copy("test.system/docker-compose.system.yml", f"{build}/tx-router/test") shutil.copy("test.system/Dockerfile.system", f"{build}/tx-router/test") shutil.copy("test.system/test_func.system.py", f"{build}/tx-router/test") os.chdir(build) load_envbash("tx-router/test/env.docker") os.environ["INIT_PLUGIN_PATH"] = "./plugin" os.environ["MONGO_INITDB_ROOT_PASSWORD"] = "******" os.environ["MONGO_NON_ROOT_PASSWORD"] = "******" os.environ["JWT_SECRET"] = "secret" os.chdir("tx-router") if cmd == "deploy": a = subprocess.run([ "docker-compose", "-f", "docker-compose.yml", "-f", "nginx/unsecure/docker-compose.yml", "up", "--build", "-V", "-t", "3000", "-d" ]) a.check_returncode() elif cmd == "down":
'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'bongcloud.wsgi.application' # Database # https://docs.djangoproject.com/en/3.0/ref/settings/#databases load_envbash(os.path.join(os.getenv('HOME'), '.bongcloud')) DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': os.environ['DB_NAME'], 'USER': os.environ['DB_USER'], 'PASSWORD': os.environ['DB_PASSWORD'], 'HOST': 'localhost', 'PORT': '', } } # Password validation # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
import tarfile from datetime import datetime import requests from envbash import load_envbash from logbook import Logger, RotatingFileHandler datetime = datetime.now() date_suffix = datetime.strftime('%Y%m%d') dir_path = os.path.dirname(os.path.realpath(__file__)) # Read settings_file and load env try: settings = json.load(open(os.path.join(dir_path, './settings.json'))) # noqa: WPS515 load_envbash('/edx/app/edxapp/edxapp_env') except IOError: sys.exit('[-] Failed to read settings file') # Configure logbook logging logger = RotatingFileHandler( settings['Logs']['logfile'], max_size=int(settings['Logs']['max_size']), backup_count=int(settings['Logs']['backup_count']), level=int(settings['Logs']['level']), ) logger.push_application() logger = Logger('mitx_etl') # Set some needed variables course_ids = []
from envbash import load_envbash load_envbash("secret/development.env") if __name__ == "__main__": from main import app app.run(host="0.0.0.0", debug=True)
from sqlalchemy.engine.url import URL import os import envbash envbash.load_envbash('../../local.bash') url_params = { 'drivername': 'postgres', 'username': os.environ.get('DATABASE_USER'), 'password': os.environ.get('DATABASE_PWD'), 'host': os.environ.get('DATABASE_HOST', 'localhost'), 'port': os.environ.get('DATABASE_PORT') } print(URL(**url_params))