def test_fixItemWithErrorFileNotFound_Delete(self): ''' Fixer should just delete Item's reference to the lost file and delete original DataRef object from database (if no other items reference to it). ''' item = self.getExistingItem(ctx.itemWithErrorFileNotFound.id) originalDataRefId = item.data_ref.id uow = self.repo.createUnitOfWork() try: itemsLock = QtCore.QReadWriteLock() fixer = IntegrityFixerFactory.createFixer( db_schema.Item.ERROR_FILE_NOT_FOUND, FileNotFoundFixer.DELETE, uow, self.repo.base_path, itemsLock) result = fixer.fix_error( item, ctx.itemWithErrorFileNotFound.ownerUserLogin) uow.session.commit() self.assertTrue(result) finally: uow.close() fixedItem = self.getExistingItem(ctx.itemWithErrorFileNotFound.id) self.assertIsNone(fixedItem.data_ref, "Item has no references to files now") originalDataRef = self.getDataRefById(originalDataRefId) self.assertIsNone( originalDataRef, "Original DataRef object should be deleted from database: no more references to it" )
def __init__(self, parent, scenariodir): QtCore.QThread.__init__(self, parent) self.setStackSize(stacksize) self.scenariodir = scenariodir self.rwlock = QtCore.QReadWriteLock() self.stopped = False self.result = 0 self.stderr = '' self.stdout = ''
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) super(MoxaSetupForm, self).__init__(parent) self.setupUi(self) self.lock = QtCore.QReadWriteLock() self.MoxaSetupThread = MoxaSetupThread(self.lock, self) self._initActions() # setup button actions
def test_fixItemWithErrorHashMismatch_TryFind_UntrackedFile(self): ''' Fixer should find an untracked file with matching hash. A new DataRef object should be created for it. Original DataRef object will be deleted, because other items do not reference to it ''' item = self.getExistingItem(ctx.itemWithErrorHashMismatch.id) originalDataRefId = item.data_ref.id originalFileHash = item.data_ref.hash uow = self.repo.createUnitOfWork() try: itemsLock = QtCore.QReadWriteLock() fixer = IntegrityFixerFactory.createFixer( db_schema.Item.ERROR_FILE_HASH_MISMATCH, FileHashMismatchFixer.TRY_FIND_FILE, uow, self.repo.base_path, itemsLock) result = fixer.fix_error( item, ctx.itemWithErrorHashMismatch.ownerUserLogin) uow.session.commit() self.assertTrue(result) finally: uow.close() fixedItem = self.getExistingItem(ctx.itemWithErrorHashMismatch.id) self.assertNotEquals(originalDataRefId, fixedItem.data_ref.id, "A new DataRef object should be created") originalDataRef = self.getDataRefById(originalDataRefId) self.assertIsNone( originalDataRef, "Original DataRef should be deleted, because there are no references to it anymore" ) foundFileAbsPath = os.path.join( self.repo.base_path, "this", "is", "untracked", "led_zeppelin_from_wikipedia.txt.original") fixedItemFileAbsPath = os.path.join(self.repo.base_path, fixedItem.data_ref.url) self.assertEquals( fixedItemFileAbsPath, foundFileAbsPath, "Item should reference to this file now {}".format( foundFileAbsPath)) self.assertTrue(os.path.exists(fixedItemFileAbsPath), "Found file should exist on filesystem") self.assertEquals(fixedItem.data_ref.hash, originalFileHash, "File hash should be still the same")
def test_fixItemWithErrorFileNotFound_TryFind_UntrackedFile(self): ''' Fixer should find an untracked file in the repo in a different location. And a new DataRef object will be created for it. Original DataRef object will be deleted (if no other items reference to it). ''' item = self.getExistingItem(ctx.itemWithErrorFileNotFound.id) originalDataRefId = item.data_ref.id uow = self.repo.createUnitOfWork() try: itemsLock = QtCore.QReadWriteLock() fixer = IntegrityFixerFactory.createFixer( db_schema.Item.ERROR_FILE_NOT_FOUND, FileNotFoundFixer.TRY_FIND, uow, self.repo.base_path, itemsLock) result = fixer.fix_error( item, ctx.itemWithErrorFileNotFound.ownerUserLogin) uow.session.commit() self.assertTrue(result) finally: uow.close() fixedItem = self.getExistingItem(ctx.itemWithErrorFileNotFound.id) self.assertNotEquals(originalDataRefId, fixedItem.data_ref.id, "A new DataRef object should be created") originalDataRef = self.getDataRefById(originalDataRefId) self.assertIsNone( originalDataRef, "Original DataRef should be deleted, because there are no references to it anymore" ) foundFileAbsPath = os.path.join(self.repo.base_path, "this", "is", "lost", "consts.py") fixedItemFileAbsPath = os.path.join(self.repo.base_path, fixedItem.data_ref.url) self.assertEquals( fixedItemFileAbsPath, foundFileAbsPath, "Item should reference to this file now {}".format( foundFileAbsPath)) self.assertTrue(os.path.exists(fixedItemFileAbsPath), "Found file should exist on filesystem")
def test_fixItemWithErrorHashMismatch_TryFind_StoredFile(self): ''' Fixer should find an existing DataRef object with matching file hash. Original DataRef object will be deleted, because other items do not reference to it. ''' item = self.getExistingItem(ctx.itemWithErrorHashMismatchNo2.id) originalDataRefId = item.data_ref.id originalFileHash = item.data_ref.hash uow = self.repo.createUnitOfWork() try: itemsLock = QtCore.QReadWriteLock() fixer = IntegrityFixerFactory.createFixer( db_schema.Item.ERROR_FILE_HASH_MISMATCH, FileHashMismatchFixer.TRY_FIND_FILE, uow, self.repo.base_path, itemsLock) result = fixer.fix_error( item, ctx.itemWithErrorHashMismatchNo2.ownerUserLogin) uow.session.commit() self.assertTrue(result) finally: uow.close() fixedItem = self.getExistingItem(ctx.itemWithErrorHashMismatchNo2.id) fixedItemFileAbsPath = os.path.join(self.repo.base_path, fixedItem.data_ref.url) self.assertTrue(os.path.exists(fixedItemFileAbsPath), "Found file should exist on filesystem") originalDataRef = self.getDataRefById(originalDataRefId) self.assertIsNone(originalDataRef, "Original DataRef object should be deleted") self.assertEquals(fixedItem.data_ref.url_raw, ctx.itemId_4.relFilePath, "Fixer should have been found this file") self.assertEquals(originalFileHash, fixedItem.data_ref.hash, "File hash should be still the same") anotherItem = self.getExistingItem(ctx.itemId_4.id) self.assertEquals( fixedItem.data_ref.id, anotherItem.data_ref.id, "Now two items reference to the same DataRef object")
def test_fixItemWithErrorFileNotFound_TryFind_StoredFile(self): ''' Fixer should find in the repo an existing DataRef object with the same matching hash. Original DataRef object should be deleted (if no other items reference to it). ''' item = self.getExistingItem(ctx.itemWithErrorFileNotFoundNo2.id) originalDataRefId = item.data_ref.id uow = self.repo.createUnitOfWork() try: itemsLock = QtCore.QReadWriteLock() fixer = IntegrityFixerFactory.createFixer( db_schema.Item.ERROR_FILE_NOT_FOUND, FileNotFoundFixer.TRY_FIND, uow, self.repo.base_path, itemsLock) result = fixer.fix_error( item, ctx.itemWithErrorFileNotFoundNo2.ownerUserLogin) uow.session.commit() self.assertTrue(result) finally: uow.close() fixedItem = self.getExistingItem(ctx.itemWithErrorFileNotFoundNo2.id) self.assertEquals(fixedItem.data_ref.url_raw, ctx.itemId_1.relFilePath, "Fixed should find this stored file") fixedItemFileAbsPath = os.path.join(self.repo.base_path, fixedItem.data_ref.url) self.assertTrue(os.path.exists(fixedItemFileAbsPath), "Found file should exist on filesystem") originalDataRef = self.getDataRefById(originalDataRefId) self.assertIsNone( originalDataRef, "Original DataRef object should be deleted from database: no more references to it" ) anotherItem = self.getExistingItem(ctx.itemId_1.id) self.assertEquals( fixedItem.data_ref.id, anotherItem.data_ref.id, "Now two different items reference to the same DataRef object")
def __init__(self, widgetsUpdateManager, mainWindow, dialogsFacade): super(ItemsTable, self).__init__() self._repo = None self._user = None self._gui = None self._actionHandlers = None #TODO: rename to guiUpdater self._widgetsUpdateManager = widgetsUpdateManager self._itemsLock = QtCore.QReadWriteLock() self._mainWindow = mainWindow self._dialogsFacade = dialogsFacade self.__dropFilesDialogs = DropFilesDialogsFacade(dialogsFacade) self._extAppMgr = ExtAppMgr() self._widgetsUpdateManager.subscribe( self._extAppMgr, self._extAppMgr.updateState, [HandlerSignals.REGGATA_CONF_CHANGED])
def __init__(self, parent=None): QtGui.QDialog.__init__(self) self.rootLabel = QtGui.QLabel(self.tr("Root Dir")) self.rootEdit = QtGui.QLineEdit() self.rootLayout = QtGui.QHBoxLayout() self.rootLayout.addWidget(self.rootLabel) self.rootLayout.addWidget(self.rootEdit) self.startButton = QtGui.QPushButton(self.tr("Start")) self.pauseButton = QtGui.QPushButton(self.tr("Pause")) self.pauseButton.setCheckable(True) self.stopButton = QtGui.QPushButton(self.tr("Stop")) self.buttonLayout = QtGui.QHBoxLayout() self.buttonLayout.addWidget(self.startButton) self.buttonLayout.addWidget(self.pauseButton) self.buttonLayout.addWidget(self.stopButton) self.formLayout = QtGui.QHBoxLayout() self.formLayout.addLayout(self.rootLayout) self.formLayout.addLayout(self.buttonLayout) self.setLayout(self.formLayout) # signals/slots # ------------------------------------------------ self.startButton.clicked.connect(self.startTask) self.connect(self.pauseButton, QtCore.SIGNAL("toggled(bool)"), self.pauseTask) self.stopButton.clicked.connect(self.stopTask) # init runner object # ------------------------------------------------ self.lock = QtCore.QReadWriteLock() self.runner = Runner(self.lock, self) # self.connect(self.runner, QtCore.SIGNAL("setProgress(string)"), self.setProgress) self.connect(self.runner, QtCore.SIGNAL("setProgress(PyQt_PyObject)"), self.setProgress) self.connect(self.runner, QtCore.SIGNAL("finished(bool)"), self.finished)
def test_fixItemWithErrorHashMismatch_UpdateHash(self): ''' Fixer should update file hash of an existing DataRef object. NOTE: We cannot create new DataRef object, without deleting the original one (because url must be unique). But we cannot delete original DataRef object if there are some items that reference to it. ''' item = self.getExistingItem(ctx.itemWithErrorHashMismatch.id) originalDataRefId = item.data_ref.id originalFileHash = item.data_ref.hash originalFilePath = item.data_ref.url_raw uow = self.repo.createUnitOfWork() try: itemsLock = QtCore.QReadWriteLock() fixer = IntegrityFixerFactory.createFixer( db_schema.Item.ERROR_FILE_HASH_MISMATCH, FileHashMismatchFixer.UPDATE_HASH, uow, self.repo.base_path, itemsLock) result = fixer.fix_error( item, ctx.itemWithErrorHashMismatch.ownerUserLogin) uow.session.commit() self.assertTrue(result) finally: uow.close() fixedItem = self.getExistingItem(ctx.itemWithErrorHashMismatch.id) self.assertEqual( fixedItem.data_ref.id, originalDataRefId, "An Existing DataRef object should have been modified") self.assertNotEquals(fixedItem.data_ref.hash, originalFileHash, "File hash should be different") self.assertEquals(fixedItem.data_ref.url_raw, originalFilePath, "File path should not be changed")
def __init__(self): QtCore.QObject.__init__(self) self.__lock = QtCore.QReadWriteLock()
def __init__(self, ppcfg, app=None, parent=None): self.cwd = ppcfg['Current working directory'] self.instr = ppcfg['instr'] self.cfgdir = ppcfg['Configuration directory'] self.ppcfg = ppcfg self.parent = parent self.ppCfgFname = './pp%s.cfg' % ppcfg['instr'] self.fail = False self.running = False self.C2_open = 655 self.C2_close = self.C2_open + 4096 # open + 90 deg self.C2_delta = 50 self.C2_delta180 = self.C2_delta + 8192 # symmetrical value at 180 deg # IMS default values for 30 Hz self.IMS_VM = 5000000 self.IMS_VI = 100000 self.IMS_A = 30000000 self.IMS_D = 30000000 self.OpenPos = 2045 self.ClosePos = 0 self.sh_status = None self.modes = {} self.modes['Mode 1'] = 'Single shot' self.modes['Mode 2'] = 'Continuous pulse rate reduction' self.modes['Mode 3'] = 'Consecutive pulse' # GUI related vars: self.nshots = None self.freq = None self.forever = None self.repeat = None self.auto = None self.sopen = None self.sclose = None self.evrdelay = None self.chkbounds = True self.sequencer = False # PV names: self.runPvname = 'SE_L' # 0, 1, 2 or 3 = not running or mode n. running self.failUDPvname = 'UD' # 1 = out of bounds self.failLDPvname = 'LD' # 1 = out of bounds self.nshotsPvname = 'N' # Number of shots to count in IMS motor trg in # Sequencer self.seqcode1 = 84 # first trigger to start moving self.seqcode2 = 85 # trigger code to DAQ and Picker self.repeatPvname = 'ECS_REPCNT_2' # repeat n times counter value self.plymodPvname = 'ECS_PLYMOD_2' # sequencer play mode 1,2,3 self.plyctrPvname = 'ECS_PLYCTL_2' # sequencer play control self.lengthPvname = 'ECS_LEN_2' # sequencer length number # self.eventcPvname = 'EC_2' # sequencer event code # self.beamdlPvname = 'BD_2' # sequencer beam tick self.eventcPvname = 'ECS_SEQ_2.A' # sequencer event code self.beamdlPvname = 'ECS_SEQ_2.B' # sequencer beam time self.tickdlPvname = 'ECS_SEQ_2.C' # sequencer beam tick self.evcodechanged = True # EVR self.evrDlyPvname = 'D' # EVR delay value self.C2Pvname = 'C2' # encoder readings self.curMode = None # current mode running in the IMS motor # PV instances: self.runPv = None self.ims_on = False self.failUDPv = None self.failLDPv = None self.nshotsPv = None self.repeatPv = None self.plymodPv = None self.lengthPv = None self.evrDlyPv = None # config file related self.sSeqPv = None # Sequencer PV base name self.sSeqDesc = None self.sPlyPv = None # Sequencer play mode self.sPlyDesc = None self.sIOC = None # IOC server name self.sIOCDesc = None self.sEvrPv = None # EVR PV base name self.sEvrDesc = None self.sPpmPv = None # IMS motor Picker PV base name self.sPpmDesc = None self.sYtrPv = None # IMS motor Y translation PV base name self.sYtrDesc = None self.sXtrPv = None # IMS motor X translation PV base name self.sXtrDesc = None self.sSPP = None # EDM screen location self.sSPPDesc = None self.sSEV = None # EDM screen location self.sSEVDesc = None self.sEVB = None # EVR burst mode delay self.sEVBDesc = None self.sEVS = None # EVR single shot mode delay self.sEVSDesc = None # alignment related: self.alignDone = False self.c2 = None self.c1 = None self.apr_000 = 655 self.apr_180 = 8704 self.alg_000 = 0 self.alg_180 = 8192 # shell commands (EDM and xterm) self.edm_ppm = False self.edm_evr = False self.srv_open = False self.aligned = False # define ca thread: self.lock = QtCore.QReadWriteLock() self.ca = CAComm(self.lock, self) self.readPVListFile() # read pv list file and associate Pvs. # disable encoder cmd = '%s:%s' % (self.sPpmPv, 'SET_EE') val = 0 self._caput(cmd, val) self._linkEPICSPV() # Connect PVs and create monitors self.connect(self.ca, QtCore.SIGNAL("Homedone"), self._onalign) self.connect(self.ca, QtCore.SIGNAL("_onOpening"), self._onOpening) self.connect(self.ca, QtCore.SIGNAL("_onOpen"), self._onOpen) self.connect(self.ca, QtCore.SIGNAL("_onClosing"), self._onClosing) self.connect(self.ca, QtCore.SIGNAL("_onClose"), self._onClose) self.connect(self.ca, QtCore.SIGNAL("_onAuto"), self._onAuto) self.event = QtCore.QObject() self.connect(self.event, QtCore.SIGNAL("_statusLDFAIL"), self._statusLDFAIL) self.connect(self.event, QtCore.SIGNAL("_statusUDFAIL"), self._statusUDFAIL) self.connect(self.event, QtCore.SIGNAL("_statusRUN"), self._statusRUN) self.connect(self.event, QtCore.SIGNAL("_onNshots"), self._onNshots) self.connect(self.event, QtCore.SIGNAL("_onEVRdelay"), self._onEVRdelay) # reset home speed and base speed: self._pr_log('Setup IMS home speed ---------------------') self._caput('%s.%s' % (self.sPpmPv, 'HVEL'), 400) self._caput('%s.%s' % (self.sPpmPv, 'HBAS'), 100) self._initEVR('Init') self._initSequencer()
def __init__(self): self.__lock = QtCore.QReadWriteLock()
def __init__(self, repo, user): super(TestsToolModel, self).__init__() self.repo = repo self.user = user self._gui = None self.itemsLock = QtCore.QReadWriteLock()