class WebRecorder(): ''' API methods are called by the RecorderPlugin in the RecorderWebService module. ''' # signal modes # TODO change mode to STATUS und ERROR... MSG_STATUS = MessageListener.MSG_STATUS # MSG_EPG = MessageListener.MSG_EPG MSG_REFRESH = MessageListener.MSG_REFRESH # Modes or types of rec? (MODE_DATA, MODE_REC, MODE_BLOCK) = range(0xA0, 0xA3) (TYPE_HEAD, TYPE_PROG, TYPE_INFO) = range(3) def __init__(self): ''' starts the app ''' self.configuration = Config() self.configuration.setupLogging("webdvb.log") self._lastMessage = None ml = MessageListener(); ml.addListener(ml.MSG_STATUS, self.storeLastMessage) # ml.addListener(ml.MSG_EPG, this.storeLastMessage) ml.addListener(ml.MSG_REFRESH, self.storeLastMessage) channelReader = ChannelReader() cPath = self.configuration.getChannelFilePath() channelReader.readChannels(cPath) self.channelList = channelReader.getChannels() self.progProvider = EPGProgramProvider(self, self.channelList, self.configuration) self._lastEpgRead = 0.0 # self._readCachedEpgData() self.checkEPGData() def _readCachedEpgData(self): ml = MessageListener(); if not self.channelList: ml.signalMessage(self.MSG_STATUS, "Where is that channel.conf? RTF!") return ml.signalMessage(self.MSG_STATUS, "Reading programm info") msg = "Idle" try: self.progProvider.readEPGCache() ml.signalMessage(self.MSG_REFRESH, "Program info read") # enforces a new list except IOError: msg = "No EPG data" except Exception, ex: msg = "Error reading cached EPG Data: " + str(ex.args[0]) self.configuration.getLogger().exception(msg) print msg self.configuration.logInfo(msg) ml.signalMessage(self.MSG_STATUS, msg)
def _connect(self): # Maybe we already have a client in this instance if self._client is not None: return # If not, we might have one from another instance self._client = ContextManager.get('GenericCacheClient', None) if self._client is not None: return # If not, create a new one backend = Config.getInstance().getCacheBackend() if backend == 'memcached': import memcache self._client = memcache.Client( Config.getInstance().getMemcachedServers()) elif backend == 'redis': self._client = RedisCacheClient( Config.getInstance().getRedisCacheURL()) elif backend == 'files': self._client = FileCacheClient( Config.getInstance().getXMLCacheDir()) else: self._client = NullCacheClient() ContextManager.set('GenericCacheClient', self._client)
def getPublicSupportEmail(self): if not hasattr(self, "_publicSupportEmail") or ( self._publicSupportEmail == "" and Config.getInstance().getPublicSupportEmail() != ""): self._publicSupportEmail = Config.getInstance( ).getPublicSupportEmail() return self._publicSupportEmail
def run_cloud(): cfg = Config('config.json') cfg.parse() gcp = CloudInterface(cfg.project, cfg.zone) master = Master(gcp, cfg.network_config, [], cfg.mapper_count, cfg.reducer_count, cfg.map_fn, cfg.reduce_fn, cfg.input_data, cfg.output_data) master.run()
def __init__(self,): self._config = Config() self._setUpLogging() self.epgUpdater = EpgUpdater(self._config) OSTools.ensureDirectory(self._config.getRecordingPath(),'') self._inhibitor = OSTools.Inhibitor() self._recordCmd = DVBDevice.getRecordCommander() self._lastJobId="0" self._recordPartIndex=0 self.isActive=True self._daemonPolicy = None
def run_cloud(): cfg = Config('config.json') cfg.parse() worker = Worker( cfg.network_config, cfg.mapper_count, cfg.reducer_count, cfg.output_data ) print('CFG parsed and worker initialized') worker.init() worker.run()
class FakeRecorder(): Command = Config().getBinPath() + "/fakezap.sh" def getArguments(self, epgInfo, durance, filePath): tArgs = [self.Command, str(durance)] tArgs.append("" + filePath + "") #No ' if shell=false return tArgs
def getXSLPath(self, stylesheet): if stylesheet.strip() != "": basepath = Config.getInstance().getStylesheetsDir() path = os.path.join(basepath, "%s.xsl" % stylesheet) if os.path.exists(path): return path return ""
def _setMailText(self): text = self.text if self.note: text = text + "Note: %s" % self.note if self.confSumary: #try: from MaKaC.common.output import outputGenerator from MaKaC.accessControl import AdminList, AccessWrapper import MaKaC.webinterface.urlHandlers as urlHandlers admin = AdminList().getInstance().getList()[0] aw = AccessWrapper() aw.setUser(admin) path = Config.getInstance().getStylesheetsDir() if os.path.exists("%s/text.xsl" % path): stylepath = "%s/text.xsl" % path outGen = outputGenerator(aw) vars = { \ "modifyURL": urlHandlers.UHConferenceModification.getURL( self.conf ), \ "sessionModifyURLGen": urlHandlers.UHSessionModification.getURL, \ "contribModifyURLGen": urlHandlers.UHContributionModification.getURL, \ "subContribModifyURLGen": urlHandlers.UHSubContribModification.getURL, \ "materialURLGen": urlHandlers.UHMaterialDisplay.getURL, \ "resourceURLGen": urlHandlers.UHFileAccess.getURL } confText = outGen.getOutput(self.conf, stylepath, vars) text += "\n\n\n" + confText #except: # text += "\n\n\nSorry could not embed text version of the agenda..." self.mail.setText(text)
def getCSSPath(self, stylesheet): if stylesheet.strip() != "": basepath = Config.getInstance().getHtdocsDir() path = os.path.join(basepath, "css", "%s.css" % stylesheet) if os.path.exists(path): return path return ""
def _setMailText(self): text = self.text if self.note: text = text + "Note: %s" % self.note if self.confSumary: #try: from MaKaC.common.output import outputGenerator from MaKaC.accessControl import AdminList, AccessWrapper import MaKaC.webinterface.urlHandlers as urlHandlers admin = AdminList().getInstance().getList()[0] aw = AccessWrapper() aw.setUser(admin) path = Config.getInstance().getStylesheetsDir() if os.path.exists("%s/text.xsl" % path): stylepath = "%s/text.xsl" % path outGen = outputGenerator(aw) vars = { \ "modifyURL": urlHandlers.UHConferenceModification.getURL( self.conf ), \ "sessionModifyURLGen": urlHandlers.UHSessionModification.getURL, \ "contribModifyURLGen": urlHandlers.UHContributionModification.getURL, \ "subContribModifyURLGen": urlHandlers.UHSubContribModification.getURL, \ "materialURLGen": urlHandlers.UHMaterialDisplay.getURL, \ "resourceURLGen": urlHandlers.UHFileAccess.getURL } confText = outGen.getOutput(self.conf,stylepath,vars) text += "\n\n\n" + confText #except: # text += "\n\n\nSorry could not embed text version of the agenda..." self.mail.setText(text)
def prerun(self): # Date checkings... from MaKaC.conference import ConferenceHolder if not ConferenceHolder().hasKey(self.conf.getId()) or \ self.conf.getStartDate() <= nowutc(): self.conf.removeAlarm(self) return True # Email self.setSubject("Event reminder: %s" % self.conf.getTitle()) try: locationText = self.conf.getLocation().getName() if self.conf.getLocation().getAddress() != "": locationText += ", %s" % self.conf.getLocation().getAddress() if self.conf.getRoom().getName() != "": locationText += " (%s)" % self.conf.getRoom().getName() except: locationText = "" if locationText != "": locationText = i18nformat(""" _("Location"): %s""") % locationText if self.getToAllParticipants(): for p in self.conf.getParticipation().getParticipantList(): self.addToUser(p) from MaKaC.webinterface import urlHandlers if Config.getInstance().getShortEventURL() != "": url = "%s%s" % (Config.getInstance().getShortEventURL(), self.conf.getId()) else: url = urlHandlers.UHConferenceDisplay.getURL(self.conf) self.setText("""Hello, Please note that the event "%s" will start on %s (%s). %s You can access the full event here: %s Best Regards """%(self.conf.getTitle(),\ self.conf.getAdjustedStartDate().strftime("%A %d %b %Y at %H:%M"),\ self.conf.getTimezone(),\ locationText,\ url,\ )) self._setMailText() return False
def getCachePath( self ): path = os.path.join(Config.getInstance().getXMLCacheDir(),self._subDirName) if not os.path.exists(path): try: os.mkdir(path) except: pass return path
def _connect(self): # Maybe we already have a client in this instance if self._client is not None: return # If not, we might have one from another instance self._client = ContextManager.get('GenericCacheClient', None) if self._client is not None: return # If not, create a new one backend = Config.getInstance().getCacheBackend() if backend == 'memcached': import memcache self._client = memcache.Client(Config.getInstance().getMemcachedServers()) else: self._client = FileCacheClient(Config.getInstance().getXMLCacheDir()) ContextManager.set('GenericCacheClient', self._client)
def prerun(self): # Date checkings... from MaKaC.conference import ConferenceHolder if not ConferenceHolder().hasKey(self.conf.getId()) or \ self.conf.getStartDate() <= nowutc(): self.conf.removeAlarm(self) return True # Email self.setSubject("Event reminder: %s"%self.conf.getTitle()) try: locationText = self.conf.getLocation().getName() if self.conf.getLocation().getAddress() != "": locationText += ", %s" % self.conf.getLocation().getAddress() if self.conf.getRoom().getName() != "": locationText += " (%s)" % self.conf.getRoom().getName() except: locationText = "" if locationText != "": locationText = i18nformat(""" _("Location"): %s""") % locationText if self.getToAllParticipants() : for p in self.conf.getParticipation().getParticipantList(): self.addToUser(p) from MaKaC.webinterface import urlHandlers if Config.getInstance().getShortEventURL() != "": url = "%s%s" % (Config.getInstance().getShortEventURL(),self.conf.getId()) else: url = urlHandlers.UHConferenceDisplay.getURL( self.conf ) self.setText("""Hello, Please note that the event "%s" will start on %s (%s). %s You can access the full event here: %s Best Regards """%(self.conf.getTitle(),\ self.conf.getAdjustedStartDate().strftime("%A %d %b %Y at %H:%M"),\ self.conf.getTimezone(),\ locationText,\ url,\ )) self._setMailText() return False
def __init__(self): obj.__init__(self) self.fromAddr = "" self.toAddr = [] self.toUser = [] self.ccAddr = [] self.subject = "" self.text = "" self.smtpServer = Config.getInstance().getSmtpServer()
class CZapCommand(): #TODO needs bin bath for arm Command = Config().getBinPath() + "/czapRecord.sh" def getArguments(self, epgInfo, durance, filePath): #czapRecord.sh durance filePath channel channelName = epgInfo.getChannel().getName() tArgs = [self.Command, str(durance)] tArgs.append("" + filePath + "") tArgs.append(channelName) return tArgs
def __init__(self, simulation_name=None, simulation_run=None, microenvironment=None, periods=None): """Initialise the simulation. Keyword Arguments: simulation_name {string} -- The name for this simulation (default: {None}) simulation_run {string} -- The sequence number for this run of the simulation (default: {None}) """ # Create a simpy environment self.env = simpy.Environment() self.dc = DataCollection(self.env, simulation_name, simulation_run) # Set the time interval relative to one hour (minutes = 1/60) self.time_interval = 1 / 60 # Number of periods the simulation will run self.periods = periods if periods else 180 # Name of microenvironment to use self.microenvironment_name = microenvironment # Routing of people through the model, nodes are decisions, edges are activities self.routing = Routing() # Import configuration information self.config = Config() self.config.import_microenvironments() self.simulation_params = { 'simpy_env': self.env, 'data_collector': self.dc, 'configuration': self.config, 'routing': self.routing, 'time_interval': self.time_interval, 'simulation_length': self.periods } # Variables in this scope only self.microenvironments = {} self.population = {}
def _sendErrorEmail(self, e): ty, ex, tb = sys.exc_info() tracebackList = traceback.format_list(traceback.extract_tb(tb)) sm = sendMail() sm.setFromAddr(Config.getInstance().getSupportEmail()) sm.addToAddr(Config.getInstance().getSupportEmail()) sm.setSubject("[Indico] Error running a task") sm.setText(""" - Details of the exception: %s - Traceback: %s -- <Indico support> indico-project @ cern.ch """ % (e, "\n".join(tracebackList))) sm.run()
def _sendErrorEmail(self, e): ty, ex, tb = sys.exc_info() tracebackList = traceback.format_list( traceback.extract_tb( tb ) ) sm = sendMail() sm.setFromAddr(Config.getInstance().getSupportEmail()) sm.addToAddr(Config.getInstance().getSupportEmail()) sm.setSubject("[Indico] Error running a task") sm.setText(""" - Details of the exception: %s - Traceback: %s -- <Indico support> indico-project @ cern.ch """%(e, "\n".join( tracebackList )) ) sm.run()
class MediaClientCommand(): Command = Config().getBinPath() + "/mediaClientRecord.sh" def getArguments(self, epgInfo, durance, filePath): channel = epgInfo.getChannel() tArgs = [ self.Command, str(durance), channel.getFrequency(), "Q" + channel.getQam(), channel.getSymbolRate(), channel.getChannelID() ] tArgs.append("" + filePath + "") return tArgs
def __init__(self): ''' starts the app ''' self.configuration = Config() self.configuration.setupLogging("webdvb.log") self._lastMessage = None ml = MessageListener() ml.addListener(ml.MSG_STATUS, self.storeLastMessage) # ml.addListener(ml.MSG_EPG, this.storeLastMessage) ml.addListener(ml.MSG_REFRESH, self.storeLastMessage) channelReader = ChannelReader() cPath = self.configuration.getChannelFilePath() channelReader.readChannels(cPath) self.channelList = channelReader.getChannels() self.progProvider = EPGProgramProvider(self, self.channelList, self.configuration) self._lastEpgRead = 0.0 # self._readCachedEpgData() self.checkEPGData()
def __init__(self): ''' starts the app ''' self.configuration = Config() self.configuration.setupLogging("dvb.log") channelReader = ChannelReader() cPath = self.configuration.getChannelFilePath() channelReader.readChannels(cPath) self.channelList = channelReader.getChannels() self.progProvider = EPGProgramProvider(self, self.channelList, self.configuration) recView = RecorderView(self.progProvider) ml = MessageListener() ml.addListener(ml.MSG_STATUS, recView.setStatusLine) ml.addListener(ml.MSG_EPG, recView.notifyEPGStatus) ml.addListener(ml.MSG_REFRESH, recView.refreshProgrammInfos) t1 = ReaderThread(False, self._readCachedEpgData) t1.start() recView.openView() #returns on close t1.join()
def __init__(self): ''' starts the app ''' self.configuration = Config() self.configuration.setupLogging("webdvb.log") self._lastMessage = None ml = MessageListener(); ml.addListener(ml.MSG_STATUS, self.storeLastMessage) # ml.addListener(ml.MSG_EPG, this.storeLastMessage) ml.addListener(ml.MSG_REFRESH, self.storeLastMessage) channelReader = ChannelReader() cPath = self.configuration.getChannelFilePath() channelReader.readChannels(cPath) self.channelList = channelReader.getChannels() self.progProvider = EPGProgramProvider(self, self.channelList, self.configuration) self._lastEpgRead = 0.0 # self._readCachedEpgData() self.checkEPGData()
def getBaseTPLPath(self): tplDir = Config.getInstance().getTPLDir() return os.path.join(tplDir, "events")
def getStyles(self): try: return self._styles except AttributeError: self._styles = Config.getInstance().getStyles() return self._styles
def _connect(self): import memcache return memcache.Client(Config.getInstance().getMemcachedServers())
def getBaseXSLPath(self): return Config.getInstance().getStylesheetsDir()
# HviConstant: # #1 - Constant name # #2 - Constant value # #3 - Constant units ('s' - seconds, 'Hz' - Herts, 'V' - Volts) # HVI: # #1 - HVI file name to load # #2 - List of HviConstants # #3 - Slot number of module to be mapped to hvi = Hvi("quadLO.HVI", [ HviModule("AWG0", [ HviConstant("NumLoops", repeats, ""), HviConstant("PulsePeriod", 150e-06, "s") ], 2), HviModule("AWG1", [], 4), HviModule("DIG0", [], 7) ]) # Config: # #1 - List of Module details # #2 - HVI details config = Config(modules, hvi) name = __name__ __name__ = "Configuration" saveConfig(config) __name__ = name config = loadConfig() log.info("Config File contents:\n{}".format(vars(config)))
def getBaseXSLPath(self): xslDir = Config.getInstance().getStylesheetsDir() return os.path.join(xslDir, "events")
def _connect(self): client = redis.StrictRedis.from_url(Config.getInstance().getRedisCacheURL()) client.connection_pool.connection_kwargs['socket_timeout'] = 1 return client
def new(cls, *args, **kwargs): backend = Config.getInstance().getCacheBackend() storageCls = cls.__CACHE_STORAGE_LIST.get(backend, cls.__CACHE_STORAGE_DEFAULT) return storageCls(*args, **kwargs)
def recover(self): self.smtpServer = Config.getInstance().getSmtpServer() TrashCanManager().remove(self)
def __init__(self, cache): super(FileCacheStorage, self).__init__(cache) self._dir = os.path.join(Config.getInstance().getXMLCacheDir(), self._name) if not os.path.exists(self._dir): os.makedirs(self._dir)
def getBaseCSSPath( self ): return os.path.join(Config.getInstance().getHtdocsDir(),"css", "events")
def getPublicSupportEmail(self): if not hasattr(self, "_publicSupportEmail") or ( self._publicSupportEmail == "" and Config.getInstance().getPublicSupportEmail() != "" ): self._publicSupportEmail = Config.getInstance().getPublicSupportEmail() return self._publicSupportEmail
def setUpClass(self): driver = Config().browser() print("Run started at:" + str(datetime.datetime.utcnow())) self.ef_driver = EventFiringWebDriver(driver, ScreenshotListener()) self.ef_driver.maximize_window()
def getBaseCSSPath(self): return os.path.join(Config.getInstance().getHtdocsDir(), "css")
def __init__(self): self._stylesheets = Config.getInstance().getStylesheets() self._eventStylesheets = Config.getInstance().getEventStylesheets() self._defaultEventStylesheet = Config.getInstance( ).getDefaultEventStylesheet()
print '++++++++++STARTING NEXT BASEDIR: ', baseDir cfg.baseDir = baseDir cfg.imgDir = baseDir + "pipeline1\\" cfg.imgDirMeta = baseDir + 'metadata.json' cfg.gifImgDir = cfg.imgDir widthAnalysis.performZoneAnalysis2(cfg.imgDir) import pdb pdb.set_trace() '''this adds a bracket to the metadata.txt (to make it a valid json) and saves it as jsn-file''' #utils.fixMetadataJSON(cfg.baseDir) '''Read configuration''' if (pipeline_step == 2): PipelineConfig, PipelineSteps, AnalysisSteps, createGifsOf = cfg.getConfigForMeasurement( baseDir) elif (pipeline_step == 3): PipelineConfig, PipelineSteps, AnalysisSteps, createGifsOf = cfg.getConfigForVesselClassification( baseDir) else: print 'Pipeline Step is not part of this program' break PipelineConfig['staticDiscRadius'], PipelineConfig[ 'staticDiscCenter'] = utils.getDiscFromFile(cfg.imgDir) ##################################################################### ''' FOLDER PREPROCESSING ''' """0.1 Create/Remove necessary folders""" if (PipelineSteps['deleteAllFolders']): createFolders.deleteAllFolders(cfg.imgDir) if (PipelineSteps['createDirs']): createFolders.createFolders(cfg.imgDir)
def __init__( self ): self._styles = Config.getInstance().getStyles() self._eventStylesheets = Config.getInstance().getEventStylesheets() self._defaultEventStylesheet = Config.getInstance().getDefaultEventStylesheet()
def _connect(self): client = redis.StrictRedis.from_url( Config.getInstance().getRedisCacheURL()) client.connection_pool.connection_kwargs['socket_timeout'] = 1 return client