def updateElement(self, id, isChecked): data = {} data['id'] = id data['is_checked'] = isChecked client = Client() LOG.info("Running updateElement()") return client.updateElement(self.setup, data)
def updateNote(self, id, isChecked): data = {} data['id'] = id data['is_checked'] = isChecked data['modified_by'] = self.user client = Client() LOG.info("Running updateNote()") return client.updateNote(self.setup, data)
def createNote(self, isChecked, text): data = {} data['text'] = text data['created_by'] = self.user data['modified_by'] = self.user data['is_checked'] = isChecked client = Client() LOG.info("Running createNote()") client.createNote(self.setup, data) return True
def getElements(self): """ Returns an array of element objects """ client = Client() try: LOG.info("Running getElements()") elements = client.getElements(self.setup) LOG.info("Lookup found: %s elements" % (len(elements))) LOG.info("Found this: %s", (elements)) return elements except ClientConnectionError, e: if 404 == e.resp.status: return []
def getNotes(self): """ Returns an array of note objects """ client = Client() try: LOG.info("Running getNotes()") notes = client.getNotes(self.setup) LOG.info("Lookup found: %s notes" % (len(notes))) LOG.info("Found this: %s", (notes)) return notes except ClientConnectionError, e: if 404 == e.resp.status: return []
def uploadFrame(self, frame): if frame.isBusy: LOG.debug("Frame was busy...") elif FRAME_DELETE == frame.status: frame.delete() elif FRAME_UPLOAD == frame.status: LOG.debug("I can work on: %s" % frame) #frame.isBusy = True #frame.save() par = 100 * float("%.5f" % frame.pixelAspectRatio) frame.resizedPath = os.path.join(frame.container, 'frame.jp2') quality = frame.quality cmd = '%s -quality %s %s -resize "%s%%x100%%" -resize "%sx%s>" %s' cmd = cmd % (self.convert, quality, frame.rgbPath, par, self.maxWidth, self.maxHeight, frame.resizedPath) LOG.debug("CMD:" + cmd) if 0 == os.system(cmd): cmd = '%s %s' % (self.identify, frame.resizedPath) (result, output) = commands.getstatusoutput(cmd) if 0 == result: match = self.identifyRegExp.search(output) if match != None: frame.resizedDepth = 8 frame.resizedWidth = match.group(1) frame.resizedHeight = match.group(2) LOG.info("MATCHED (%s) X (%s)!" % (frame.resizedWidth, frame.resizedHeight)) LOG.info("FRAME (%s) STATUS (%s)" % (frame, frame.status)) client = Client() client.createFrame(frame) LOG.debug("done!") frame.delete() else: raise ValueError("DID NOT MATCH identify group!") else: raise ValueError("identify did not return 0!") else: raise ValueError("FAILURE running convert") elif FRAME_UNKNOWN == frame.status: # unknown frame -- check if the pid that generated it # is still running. If not, it can be deleted if not self.isPidRunning(frame.pid): LOG.info("The pid (%s) that generated (%s) is no longer running" % (frame.pid, frame)) frame.delete()
def flushEventQueue(self): LOG.info("(((( flushing event queue ))))") key = '_LAST_EVENT_' while self.events: appEvent = self.events.pop(0) if isinstance(appEvent, DiscreetAppBatchProcessEvent): # wait until we flush the queue to determine the batch outputs appEvent.outputs = self.outputs.keys() lastEvent = None if key in os.environ: lastEvent = float(os.environ[key]) eventSeconds = float(datetimeToSeconds(appEvent.date)) if lastEvent is None or eventSeconds > lastEvent: LOG.debug("SENDING EVENT... LOOKS GOOD") try: client = Client() if appEvent.job: client.createRender(appEvent) else: client.createEvent(appEvent) except Exception, e: LOG.warn("Error sending event: %s [%s]" % (e, type(e))) # set the last event time, even if it failed # an event is either a success or failure # only setting this on success would allow for retries # if a person exited batch and re-entered -- don't think # that is what we want # # explictly state the precision of the float os.environ[key] = "%.6f" % eventSeconds else: LOG.debug("SKIPPING EVENT! LAST EVENT WAS MORE RECENT...")