def test_yamify(self): xpdobj = XPD() xpdobj.name = ' test' xpdobj.type = 'b t' yaml_dir = glbl.yaml_dir objlist = [] lname = os.path.join(yaml_dir,'_acqobj_list.yml') #initialize the objlist yaml file if it doesn't exist if not os.path.isfile(lname): fo = open(lname, 'w') yaml.dump(objlist, fo) testfname = os.path.join(yaml_dir,'bt_test.yml') probe = xpdobj._yamify() newobjlist = _get_yaml_list() self.assertEqual(newobjlist,self.stbt_list+['bt_test.yml']) xpdobj2 = XPD() xpdobj2.name = ' test2' xpdobj2.type = 'b t' testfname2 = os.path.join(yaml_dir,'bt_test2.yml') probe2 = xpdobj2._yamify() newobjlist2 = _get_yaml_list() self.assertEqual(newobjlist2,self.stbt_list+['bt_test.yml','bt_test2.yml']) self.assertEqual(probe,testfname) self.assertTrue(os.path.isfile(probe)) # try adding another item that is already there probe3 = xpdobj2._yamify() newobjlist3 = _get_yaml_list() self.assertEqual(newobjlist3,self.stbt_list+['bt_test.yml','bt_test2.yml'])
from xpdacq.beamtimeSetup import _make_clean_env from xpdacq.beamtime import XPD from simulator.areadetector import AreaDetector WORKING_DIR = 'xpdUser' B_DIR = os.getcwd() datapath = DataPath(B_DIR) pe1c = AreaDetector(0.1) print('Initializing the XPD data acquisition simulation environment') _make_clean_env(datapath) os.chdir(os.path.join(B_DIR,WORKING_DIR)) #if there is a yml file in the normal place, then load the beamtime object if len(XPD.loadyamls()) > 0: bt = XPD.loadyamls()[0] ''' print('Flushing directories under simulation tree') datapath = DataPath('./') for dir in datapath.allfolders: try: flush_dir(dir) except FileNotFoundError: print(dir + ' error') pass os.chdir(datapath.base) print('\n') '''
from xpdacq.beamtimeSetup import * from xpdacq.beamtimeSetup import _make_clean_env from xpdacq.beamtime import XPD from simulator.areadetector import AreaDetector WORKING_DIR = 'xpdUser' B_DIR = os.getcwd() datapath = DataPath(B_DIR) pe1c = AreaDetector(0.1) print('Initializing the XPD data acquisition simulation environment') _make_clean_env(datapath) os.chdir(os.path.join(B_DIR, WORKING_DIR)) #if there is a yml file in the normal place, then load the beamtime object if len(XPD.loadyamls()) > 0: bt = XPD.loadyamls()[0] ''' print('Flushing directories under simulation tree') datapath = DataPath('./') for dir in datapath.allfolders: try: flush_dir(dir) except FileNotFoundError: print(dir + ' error') pass os.chdir(datapath.base) print('\n') '''
def test_yamify(self): xpdobj = XPD() xpdobj.name = ' test' xpdobj.type = 'b t' yaml_dir = glbl.yaml_dir objlist = [] lname = os.path.join(yaml_dir, '_acqobj_list.yml') #initialize the objlist yaml file if it doesn't exist if not os.path.isfile(lname): fo = open(lname, 'w') yaml.dump(objlist, fo) testfname = os.path.join(yaml_dir, 'bt_test.yml') probe = xpdobj._yamify() newobjlist = _get_yaml_list() self.assertEqual(newobjlist, self.stbt_list + ['bt_test.yml']) xpdobj2 = XPD() xpdobj2.name = ' test2' xpdobj2.type = 'b t' testfname2 = os.path.join(yaml_dir, 'bt_test2.yml') probe2 = xpdobj2._yamify() newobjlist2 = _get_yaml_list() self.assertEqual(newobjlist2, self.stbt_list + ['bt_test.yml', 'bt_test2.yml']) self.assertEqual(probe, testfname) self.assertTrue(os.path.isfile(probe)) # try adding another item that is already there probe3 = xpdobj2._yamify() newobjlist3 = _get_yaml_list() self.assertEqual(newobjlist3, self.stbt_list + ['bt_test.yml', 'bt_test2.yml'])