substitute( "configure/RELEASE.pre", "configure/RELEASE", { "%{EPICS_BASE}": os.environ["EPICS_BASE"], }, ) try_make_dir("./lib") try_make_dir("./lib/" + os.environ["EPICS_HOST_ARCH"]) def binding(): assert run(["cargo", "build"], cwd="./device_support").returncode == 0 src_dir = "./device_support/target/debug/" dst_dir = "./lib/" + os.environ["EPICS_HOST_ARCH"] + "/" libs = ["libdevice_support.a", "libdevice_support.so"] try_make_dir(dst_dir) for lib in libs: copy_file(src_dir + lib, dst_dir + lib) def build(): prepare() binding() assert run(["make", "-f", "Makefile.pre"]).returncode == 0 if __name__ == "__main__": setup() build()
def main(test=False, **kwargs): # The master configuration object config = {} # A list of all the threads thread_list = [] # An event to kill the threads on terminal exception thread_kill_event = threading.Event() mutex = threading.Lock() display_event = threading.Event() debug = False from_saved_state = False # A flag to tell if we have all the data locally all_data = False all_data_remote = False # get a globus client client = get_client() # Read in parameters from config args = kwargs['testargs'] if test else sys.argv[1:] config, filemanager, runmanager = setup(args, display_event, event_list=event_list, thread_list=thread_list, kill_event=thread_kill_event, mutex=mutex) if isinstance(config, int): print "Error in setup, exiting" return -1 logging.info('Config setup complete') logging.info(str(config)) # check that all netCDF files exist path_exists(config) # cleanup any temp directories from previous runs # cleanup(config) if not os.path.exists(config['global']['run_scripts_path']): os.makedirs(config['global']['run_scripts_path']) if not os.path.exists(config['global']['tmp_path']): os.makedirs(config['global']['tmp_path']) if config['global'].get('ui'): try: sys.stdout.write('Turning on the display') for i in range(8): sys.stdout.write('.') sys.stdout.flush() sleep(0.1) print '\n' args = (display_event, runmanager.job_sets) diaplay_thread = threading.Thread(target=start_display, args=args) diaplay_thread.start() except KeyboardInterrupt as e: print 'keyboard exit' display_event.set() return -1 state_path = os.path.join( config.get('global').get('output_path'), 'run_state.txt') filemanager.update_local_status() all_data = filemanager.all_data_local() if not all_data: print "Updating remote file status" filemanager.update_remote_status(client) all_data_remote = filemanager.all_data_remote() write_human_state(event_list=event_list, job_sets=runmanager.job_sets, state_path=state_path, print_file_list=config['global'].get('print_file_list'), mutex=mutex) dryrun = config['global'].get('dry_run') if dryrun: runmanager.dryrun(True) event_list.push(message='Running in dry-run mode') write_human_state( event_list=event_list, job_sets=job_sets, state_path=state_path, print_file_list=config['global'].get('print_file_list'), mutex=mutex) if config['global'].get('ui'): sleep(50) display_event.set() for t in thread_list: thread_kill_event.set() t.join(timeout=1.0) return -1 # check if the case_scripts directory is present # if its not, transfer it over case_scripts_dir = os.path.join(config['global']['input_path'], 'case_scripts') if not os.path.exists(case_scripts_dir) \ and not config['global']['no_monitor']: msg = 'case_scripts not local, transfering remote copy' print msg event_list.push(message=msg) logging.info(msg) src_path = os.path.join(config['global']['source_path'], 'case_scripts') while True: try: args = { 'source_endpoint': config['transfer']['source_endpoint'], 'destination_endpoint': config['transfer']['destination_endpoint'], 'src_path': src_path, 'dst_path': case_scripts_dir, 'event_list': event_list, 'event': thread_kill_event } thread = threading.Thread(target=transfer_directory, name='transfer_directory', kwargs=args) except: sleep(1) else: thread_list.append(thread) thread.start() break # Main loop remote_check_delay = 60 local_check_delay = 2 printed = False try: loop_count = remote_check_delay print "--- Entering main loop ---" print "Current status can be found at {}".format(state_path) while True: # Check the remote status once every 5 minutes if loop_count == remote_check_delay: loop_count = 0 if config.get('global').get('no_monitor', False): loop_count += 1 continue if not all_data: all_data = filemanager.all_data_local() if not all_data_remote and not all_data: all_data_remote = filemanager.all_data_remote() if not all_data_remote and not all_data: print 'Updating remote status' filemanager.update_remote_status(client) if not all_data: print 'Updating local status' filemanager.update_local_status() # check the local status every 10 seconds if loop_count == local_check_delay: if not all_data: all_data = filemanager.all_data_local() else: if not printed: print 'All data local, turning off remote checks' printed = True if not all_data \ and not config['global']['no_monitor']: transfer_started = filemanager.transfer_needed( event_list=event_list, event=thread_kill_event, remote_endpoint=config['transfer']['source_endpoint'], ui=config['global']['ui'], display_event=display_event, emailaddr=config['global']['email'], thread_list=thread_list) if transfer_started: print 'starting file transfer' filemanager.check_year_sets(runmanager.job_sets) runmanager.start_ready_job_sets() runmanager.monitor_running_jobs() write_human_state( event_list=event_list, job_sets=runmanager.job_sets, state_path=state_path, print_file_list=config.get('global').get('print_file_list'), mutex=mutex) status = runmanager.is_all_done() if status >= 0: first_print = True while not filemanager.all_data_local(): if first_print: print "All jobs complete, moving additional files" first_print = False started = filemanager.transfer_needed( event_list=event_list, event=thread_kill_event, remote_endpoint=config['transfer']['source_endpoint'], ui=config['global']['ui'], display_event=display_event, emailaddr=config['global']['email'], thread_list=thread_list) if not started: sleep(5) else: print "Transfer started" finishup(config=config, job_sets=runmanager.job_sets, state_path=state_path, event_list=event_list, status=status, display_event=display_event, thread_list=thread_list, kill_event=thread_kill_event) # SUCCESS EXIT return 0 sleep(5) loop_count += 1 except KeyboardInterrupt as e: print_message('----- KEYBOARD INTERRUPT -----') print_message('----- cleaning up threads ---', 'ok') event_list.push(message="Exiting due to keyboard interrupt") write_human_state(event_list=event_list, job_sets=runmanager.job_sets, state_path=state_path, print_file_list=True, mutex=mutex) display_event.set() thread_kill_event.set() for thread in thread_list: thread.join(timeout=1.0) except Exception as e: print_message('----- UNEXPECTED EXCEPTION OCCURED -----') print_debug(e) display_event.set() thread_kill_event.set() for thread in thread_list: thread.join(timeout=1.0)
# PixelGame Installer # NOTE # This script will create a pixelgame installation file. to install # pixelgame, execute this script and run the pixelgame.bat file which # will appear in the same directory as this script. # INSTALLATION # The PixelGame will be installed in the same parent directory as # this folder. For example, if the 'pixelgame_installer/' folder is # located in 'C:\Users\<user>\Desktop\pixelgame_installer\', the # PixelGame will be installed In 'C:\Users\<user>\Desktop\pixelgame\' from lib import setup # INSTALLER PREPARATION ----- setup.setup() # CREATE THE INSTALLER ------ from lib import installer_setup installer_setup.installer()
__author__="kayapo" __date__ ="$2011.02.14. 12:22:35$" import cgi import json import time import re from lib.log import log from lib.db import db from lib.setup import setup from lib.JSONify import JSONify SET = setup() dbObj = db(SET.getMySQLhost(), SET.getMySQLuser(), SET.getMySQLpassword(), SET.getMySQLdatabase()) dbConn = dbObj.connector() def getTags(): tags = list() unreliableTags = dbObj.runQuery(dbConn, "SELECT tag FROM %s GROUP BY tag;" % SET.getMySQLtable()) for tag in unreliableTags: tags.append( {"tag":cgi.escape(tag["tag"], 1)} ) if SET.getLogLevel() >= 3: L = log(0, 0, "logwalker.getTags") L.logger(str(tags)) return tags
import lib.templates as templates from lib.GPIO import GPIO from lib.setup import setup from lib.ws import WS ROOT_DIR = os.getcwd() if __name__ == "__main__": GPIO.setup_leds() GPIO.turn_off_all_led() GPIO.blink_alert_led(on_time=0.05, off_time=0.05) sleep(10) SETUP = setup() if isinstance(SETUP, str): print(SETUP) print("Error occured") GPIO.error() sleep(10) os.system('sudo python3 /home/pi/printer/main.py') else: with open("/home/pi/printer/conf/conf.json", "r") as conf: configuration = json.load(conf) URL = configuration.get("ticketbutler").get("URL")