def process(): if len(sys.argv) <= 1: # default behavior, run general test print "" nfail = module_test_lib.num_import_failures(verb=2) print "\nnumber of python import failures = %d\n" % nfail return nfail # create elemnnt and initialize options MT = ModuleTest() MT.init_opts() # read options, return on terminal option or bad usage rv = MT.read_opts() if rv != None: if rv: MT.show_failed_command() return rv # apply options rv = MT.process_opts() if rv != None: if rv: MT.show_failed_command() return rv # do stuff rv = MT.execute() if rv != None: if rv: MT.show_failed_command() return rv
def __init__(self, sport, verb=1): global g_SER # global reference for serial library # see if the serial library is available if module_test_lib.num_import_failures(['serial']): return None import serial g_SER = serial # main variables self.verb = verb # verbose level self.port_file = sport # file for serial port self.data_port = None # serial data port self.swap = 0 # whether to swap serial bytes if self.verb > 1: print '++ initializing serial interface %s...' % sport
def __init__(self, sport, verb=1): global g_SER # global reference for serial library # see if the serial library is available if module_test_lib.num_import_failures(['serial']): return None import serial g_SER = serial # main variables self.verb = verb # verbose level self.port_file = sport # file for serial port self.data_port = None # serial data port self.swap = 0 # whether to swap serial bytes if self.verb > 1: print('++ initializing serial interface %s...' % sport)
def set_demo_gui(self): """create the GUI for display of the demo data""" testlibs = ['numpy', 'wx'] if module_test_lib.num_import_failures(testlibs): sys.exit(1) import numpy as N, wx import lib_RR_plot as LPLOT self.wx_app = wx.App() self.demo_frame = LPLOT.CanvasFrame(title='receiver demo') self.demo_frame.EnableCloseButton(True) self.demo_frame.Show(True) self.demo_frame.style = 'bar' self.demo_frame.xlabel = 'most recent 10 TRs' self.demo_frame.ylabel = 'scaled diff_ratio' # for the current demo, set an ranges for 10 numbers in [0,10] if self.demo_frame.style == 'graph': self.demo_frame.set_limits(0,9.1,-0.1,10.1) elif self.demo_frame.style == 'bar': self.demo_frame.set_limits(0,10.1,-0.1,10.1)
def execute(self): if self.show_pyver: if self.verb <= 1: vlist = sys.version.split() vstr = vlist[0] else: vstr = sys.version print 'python version: %s' % vstr if self.show_platform: try: import platform print 'platform: %s' % platform.platform() except: print 'platform: ** module not found' if self.show_modtest: nfail = module_test_lib.num_import_failures(self.modlist, details=1,verb=self.verb) print "\nnumber of python import failures = %d\n" % nfail return None
def set_demo_gui(self): """create the GUI for display of the demo data""" testlibs = ["numpy", "wx"] if module_test_lib.num_import_failures(testlibs): return 1 try: import numpy as N, wx import lib_RR_plot as LPLOT except: return 1 self.wx_app = wx.App() self.demo_frame = LPLOT.CanvasFrame(title="receiver demo") self.demo_frame.EnableCloseButton(True) self.demo_frame.Show(True) self.demo_frame.style = "bar" self.demo_frame.xlabel = "most recent 10 TRs" self.demo_frame.ylabel = "scaled diff_ratio" # for the current demo, set an ranges for 10 numbers in [0,10] if self.demo_frame.style == "graph": self.demo_frame.set_limits(0, 9.1, -0.1, 10.1) elif self.demo_frame.style == "bar": self.demo_frame.set_limits(0, 10.1, -0.1, 10.1)
def execute(self): if self.show_pyver: if self.verb <= 1: vlist = sys.version.split() vstr = vlist[0] else: vstr = sys.version print 'python version: %s' % vstr if self.show_platform: try: import platform print 'platform: %s' % platform.platform() except: print 'platform: ** module not found' if self.show_modtest: nfail = module_test_lib.num_import_failures(self.modlist, details=1, verb=self.verb) print "\nnumber of python import failures = %d\n" % nfail return None
def test_libraries(self,verb=2): """test for existence of needed python libraries""" import module_test_lib as MLT libs = ['os', 'gc', 'numpy', 'wx', 'matplotlib', 'scipy'] if MLT.num_import_failures(libs,details=1,verb=verb): return 1 else: return 0
#!/usr/bin/env python # a basic realtime_receiver plotting library import sys, os # verify system libraries import module_test_lib g_testlibs = ['gc', 'numpy', 'wx', 'matplotlib'] if module_test_lib.num_import_failures(g_testlibs, details=0): print """ -- for details, consider xmat_tool -test_libs -- also, many computations do not require the GUI (e.g. 'xmat_tool -load_xmat X.xmat.1D -show_cormat_warnings') """ sys.exit(1) import numpy as N import gc # must use matplotlib with wx, not pylab import wx import matplotlib matplotlib.use('WX') # set some resource font values matplotlib.rc('axes', titlesize=11) matplotlib.rc('axes', labelsize=9) matplotlib.rc('xtick', labelsize=8) matplotlib.rc('ytick', labelsize=7)
#!/usr/bin/env python # python3 status: started # library for performing various system checks import os, sys import module_test_lib as MT # test dependency libs before proceeding # note: platform came with python 2.3 testlibs = ['platform', 'afni_base', 'afni_util'] if MT.num_import_failures(testlibs): sys.exit(1) import platform, glob import afni_base as BASE import afni_util as UTIL class SysInfo: """system info class""" def __init__(self, data_root='', verb=1): self.system = platform.system() self.home_dir = os.environ['HOME'] self.data_root = data_root self.verb = verb self.afni_ver = '' self.afni_label = ''
def set_demo_gui(self): """create the GUI for display of the demo data""" testlibs = ['numpy', 'wx'] if module_test_lib.num_import_failures(testlibs): sys.exit(1) import numpy as N, wx
#!/usr/bin/env python import sys import module_test_lib g_testlibs = ['sys', 'math', 'numpy'] if module_test_lib.num_import_failures(g_testlibs): sys.exit(1) # import libraries import math import copy import numpy as N import afni_util as UTIL import lib_textdata as TD class AfniXmat: def __init__(self, filename="", from_mat=0, matrix=None, verb=1): """numpy matrix class init from filename or matrix, filename : 1D file to read in as matrix from_mat : use matrix for initialization (numpy or []) matrix : Numpy matrix to use if from_mat is set verb : verbose level of operations mat : data fname : filename rows, cols : dimensions labels : simple text labels groups : list: -1 (baseline), 0 (motion), else reg index
#!/usr/bin/env python # library for performing various system checks import os, sys import module_test_lib as MT # test dependency libs before proceeding # note: platform came with python 2.3 testlibs = ['platform', 'afni_base', 'afni_util'] if MT.num_import_failures(testlibs): sys.exit(1) import platform, glob import afni_base as BASE import afni_util as UTIL class SysInfo: """system info class""" def __init__(self, data_root='', verb=1): self.system = platform.system() self.home_dir = os.environ['HOME'] self.data_root = data_root self.verb = verb self.afni_ver = '' self.os_dist = '' self.comments = [] # comments to print at the end
#!/usr/bin/env python # basically, a GUI to write an afni_proc.py command import sys, os, copy, math # system libraries : test, then import as local symbols import module_test_lib testlibs = ['copy', 'signal'] if module_test_lib.num_import_failures(testlibs): sys.exit(1) import copy import afni_util as UTIL import lib_subjects as SUBJ import lib_vars_object as VO import lib_uber_skel as USKEL import option_list as OPT g_command_help = """ =========================================================================== uber_skel.py - sample uber processing program (based on uber_align_test.py, version 0.2) usage: uber_skel.py --- This help describes only the command line options to this program, which enables one to: - initialize user variables (for GUI or command line)
#!/usr/bin/env python # basically, a GUI to write an afni_proc.py command import sys, os, copy, math # system libraries : test, then import as local symbols import module_test_lib testlibs = ["copy", "signal"] if module_test_lib.num_import_failures(testlibs): sys.exit(1) import copy import afni_util as UTIL import lib_subjects as SUBJ import lib_uber_align as UALIGN import option_list as OPT g_command_help = """ =========================================================================== uber_align_test.py - generate script to test anat/EPI alignment usage: uber_align_test.py --- This help describes only the command line options to this program, which enables one to: - initialize user variables (for GUI or command line)
#!/usr/bin/env python # a basic realtime_receiver plotting library import sys, os # verify system libraries import module_test_lib g_testlibs = ['gc', 'numpy', 'wx', 'matplotlib'] if module_test_lib.num_import_failures(g_testlibs,details=0): print """ -- for details, consider xmat_tool -test_libs -- also, many computations do not require the GUI (e.g. 'xmat_tool -load_xmat X.xmat.1D -show_cormat_warnings') """ sys.exit(1) import numpy as N import gc # must use matplotlib with wx, not pylab import wx import matplotlib matplotlib.use('WX') # set some resource font values matplotlib.rc('axes',titlesize=11) matplotlib.rc('axes',labelsize=9) matplotlib.rc('xtick',labelsize=8) matplotlib.rc('ytick',labelsize=7)
def test_libraries(self, verb=2): """test for existence of needed python libraries""" import module_test_lib as MLT libs = ['os', 'gc', 'numpy', 'wx', 'matplotlib', 'scipy'] if MLT.num_import_failures(libs, details=1, verb=verb): return 1 else: return 0