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 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
# This module holds: # # RTInterface: the real-time socket interface, for receiving data # from the real-time plugin to afni over a TCP port. # # SerialInterface: interface for writing to a serial port. # ---------------------------------------------------------------------- from __future__ import print_function import sys, os # system libraries : test, then import as local symbols from afnipython import module_test_lib testlibs = ['time', 'socket', 'struct'] if module_test_lib.num_import_failures(testlibs): sys.exit(1) import time, socket, struct # AFNI libraries (besides module_test_lib) import afnipython.option_list as OL import afnipython.afni_util as UTIL # not actually used, but probably will be # ---------------------------------------------------------------------- # globals g_RTinterface = None # global reference to main class g_magic_hi = [0xab, 0xcd, 0xef, 0xab] g_magic_bye = [0xde, 0xad, 0xde, 0xad] g_magic_len = 4 g_start_time = 0 # time for starting a new run
#!/usr/bin/env python # python3 status: started # library for performing various system checks import os, sys import afnipython.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 afnipython.afni_base as BASE import afnipython.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 = ''
#!/usr/bin/env python import sys # verify system libraries from afnipython import module_test_lib g_testlibs = ['wx'] 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 wx import wx.grid # ====================================================================== # text window combo class class TextCombo(wx.Panel): def __init__(self, parent, id): wx.Panel.__init__(self, parent, id) # ---------------------------------------- # create TextCtrl portion self.ctrl = wx.TextCtrl(self, -1, style = wx.TE_MULTILINE) # ----------------------------------------
def test_libraries(self,verb=2): """test for existence of needed python libraries""" import afnipython.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