def _test_main_review_error(self): """ Run review feature without envvar set """ os.setenv('IMGCAT', None) with self.assertRaises(ValueError): scenes = main.main(date='2017-01-01', satellite_name='Landsat-8', review=True)
def main(): parser = ArgumentParser(description='MyRPG project launcher') parser.add_argument('proj', nargs=1, help='Path to MyRPG project file', required=True) args = parser.parse_args() if not os.path.exists(args.proj): six.print_('Cannot find project:', args.proj, file=sys.stderr) sys.exit(1) try: with open(args.proj) as f: proj = json.load(f) except IOError as err: six.print_('Cannot open project:', err, file=sys.stderr) sys.exit(1) except ValueError as err: six.print_('Cannot parse project:', err, file=sys.stderr) sys.exit(1) os.setenv('B3J0F_CONF_DIR', proj['directory']) app = Application() app.run()
def fix_env(self): android_path = os.getenv('ANDROID_PRIVATE') self._is_android = bool(android_path) if not android_path: return os.setenv('HOME', android_path) assert os.path.exists(android_path)
def runmd5(num): global encoded global stop start = BASENUM * (int(num)) i = start while i <= start * 10: if os.getenv('runmd5') or stop: break if md5x(str(i))[0:6] == encoded: print('DeCode : %d\n' % i) os.setenv('runmd5', '1') stop = True return i i += 1 return False
import glob, os, optparse parser = optparse.OptionParser() (options,args) = parser.parse_args() runlevel = args[0] scenarios = glob.glob('scenario*') print('running model for') print(scenarios) print('with run level') print(runlevel) os.putenv('RUNLEVEL',runlevel) os.setenv('HHSINMEM','0') for s in scenarios: print('running for '+s+'...') os.chdir(s) os.system(r'copy hwy\ ..\run\hwy') os.system(r'copy trn\transit_lines\ ..run\trn') os.system(r'copy trn\transit_fares\ ..run\trn') os.system(r'copy trn\transit_support\ ..run\trn') os.chdir(r'..\run') if os.getenv('HHSINMEM') == '1': os.system('runQuickModel') print('calculating metrics...') os.system('runMetrics') print('copying metrics to scenario directory...') os.system(r'copy metrics\ ..\'+s+r'\metrics\')
def create_interactive_env(d): for k in preserved_envvars_exported_interactive(): os.setenv(k, bb.data.getVar(k, d, True))
def create_interactive_env(d): for k in preserved_envvars_exported_interactive(): os.setenv(k, d.getVar(k, True))
To run these tests from the command line in a local VM, you'll need to: > python selenium_tests/regression_suite.py """ import os import sys import time import unittest from django.conf import settings # set up PYTHONPATH and DJANGO_SETTINGS_MODULE. icky, but necessary sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) if not os.getenv('DJANGO_SETTINGS_MODULE'): os.setenv('DJANGO_SETTINGS_MODULE', 'canvas_course_info.settings.local') # developing test cases is easier with text test runner, lets us drop into pdb if settings.SELENIUM_CONFIG.get('use_htmlrunner', True): import HTMLTestRunner dateTimeStamp = time.strftime('%Y%m%d_%H_%M_%S') buf = file("TestReport" + "_" + dateTimeStamp + ".html", 'wb') runner = HTMLTestRunner.HTMLTestRunner( stream=buf, title='Test the Report', description='Result of tests' ) else: import logging; logging.basicConfig(level=logging.DEBUG) runner = unittest.TextTestRunner()
import aicrowd_helpers import time import traceback import glob import os import json """ Expected ENVIRONMENT Variables * AICROWD_TEST_IMAGES_PATH : abs path to folder containing all the test images * AICROWD_PREDICTIONS_OUTPUT_PATH : path where you are supposed to write the output predictions.csv """ AICROWD_TEST_IMAGES_PATH = os.setenv('AICROWD_TEST_IMAGES_PATH', 'data/round1') AICROWD_PREDICTIONS_OUTPUT_PATH = os.setenv('AICROWD_PREDICTIONS_OUTPUT_PATH', 'random_prediction.csv') def gather_images(test_images_path): images = glob.glob(os.path.join( test_images_path, "*.jpg" )) return images def gather_image_names(test_images_path): images = gather_images(test_images_path) image_names = [os.path.basename(image_path) for image_path in images] return image_names def get_image_path(image_name): test_images_path = os.getenv("AICROWD_TEST_IMAGES_PATH", False)
def multi_cpu(func, job_queue, cpu_num=1, thread_num=1, timeout=None): multicpu_instance = Multicpu(cpu_num, thread_num) return multicpu_instance._multi_cpu(func, job_queue, timeout) def runmd5(num): global encoded global stop start = BASENUM * (int(num)) i = start while i <= start * 10: if os.getenv('runmd5') or stop: break if md5x(str(i))[0:6] == encoded: print('DeCode : %d\n' % i) os.setenv('runmd5', '1') stop = True return i i += 1 return False if __name__ == '__main__': global encoded encoded = raw_input('code : ') while encoded: os.setenv('runmd5', '0') print('Runing... %s' % encoded) m = multi_cpu(runmd5, [i for i in range(1, 100)], 5, 10) print(m) encoded = raw_input('code : ')
""" Copyright (c) 2013 Sébastien QUIOC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ import os import os.path import sys paths = set(os.getenv("PATH","").split(os.path.pathsep)) for path_file in sys.argv[1:]: with open(path_file) as f: for path in f.readlines(): paths.add(path.strip()) os.setenv("PATH", os.path.pathsep.join(paths))