Exemplo n.º 1
0
 def getPublicSupportEmail(self):
     if not hasattr(self, "_publicSupportEmail") or (
             self._publicSupportEmail == ""
             and Config.getInstance().getPublicSupportEmail() != ""):
         self._publicSupportEmail = Config.getInstance(
         ).getPublicSupportEmail()
     return self._publicSupportEmail
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 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 ""
Exemplo n.º 6
0
 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 ""
Exemplo n.º 7
0
 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 ""
Exemplo n.º 8
0
 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 ""
Exemplo n.º 9
0
    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
Exemplo n.º 10
0
    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)
Exemplo n.º 11
0
    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
Exemplo n.º 12
0
 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
Exemplo n.º 13
0
 def __init__(self):
     obj.__init__(self)
     self.fromAddr = ""
     self.toAddr = []
     self.toUser = []
     self.ccAddr = []
     self.subject = ""
     self.text = ""
     self.smtpServer = Config.getInstance().getSmtpServer()
Exemplo n.º 14
0
 def __init__(self):
     obj.__init__(self)
     self.fromAddr = ""
     self.toAddr = []
     self.toUser = []
     self.ccAddr = []
     self.subject = ""
     self.text = ""
     self.smtpServer = Config.getInstance().getSmtpServer()
Exemplo n.º 15
0
    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()
Exemplo n.º 16
0
    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()
Exemplo n.º 17
0
 def getBaseTPLPath(self):
     tplDir = Config.getInstance().getTPLDir()
     return os.path.join(tplDir, "events")
Exemplo n.º 18
0
 def getStyles(self):
     try:
         return self._styles
     except AttributeError:
         self._styles = Config.getInstance().getStyles()
         return self._styles
Exemplo n.º 19
0
 def __init__( self ):
     self._styles = Config.getInstance().getStyles()
     self._eventStylesheets = Config.getInstance().getEventStylesheets()
     self._defaultEventStylesheet = Config.getInstance().getDefaultEventStylesheet()
Exemplo n.º 20
0
 def getBaseXSLPath(self):
     xslDir = Config.getInstance().getStylesheetsDir()
     return os.path.join(xslDir, "events")
Exemplo n.º 21
0
 def _connect(self):
     client = redis.StrictRedis.from_url(
         Config.getInstance().getRedisCacheURL())
     client.connection_pool.connection_kwargs['socket_timeout'] = 1
     return client
Exemplo n.º 22
0
 def getBaseCSSPath(self):
     return os.path.join(Config.getInstance().getHtdocsDir(), "css")
Exemplo n.º 23
0
 def _connect(self):
     import memcache
     return memcache.Client(Config.getInstance().getMemcachedServers())
Exemplo n.º 24
0
 def getBaseTPLPath(self):
     tplDir = Config.getInstance().getTPLDir()
     return os.path.join(tplDir, "events")
Exemplo n.º 25
0
 def new(cls, *args, **kwargs):
     backend = Config.getInstance().getCacheBackend()
     storageCls = cls.__CACHE_STORAGE_LIST.get(backend, cls.__CACHE_STORAGE_DEFAULT)
     return storageCls(*args, **kwargs)
Exemplo n.º 26
0
 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)
Exemplo n.º 27
0
 def recover(self):
     self.smtpServer = Config.getInstance().getSmtpServer()
     TrashCanManager().remove(self)
Exemplo n.º 28
0
 def getBaseXSLPath(self):
     return Config.getInstance().getStylesheetsDir()
Exemplo n.º 29
0
 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)
Exemplo n.º 30
0
 def getBaseXSLPath(self):
     xslDir = Config.getInstance().getStylesheetsDir()
     return os.path.join(xslDir, "events")
Exemplo n.º 31
0
 def getBaseXSLPath(self):
     return Config.getInstance().getStylesheetsDir()
Exemplo n.º 32
0
 def getBaseCSSPath( self ):
     return os.path.join(Config.getInstance().getHtdocsDir(),"css", "events")
Exemplo n.º 33
0
 def new(cls, *args, **kwargs):
     backend = Config.getInstance().getCacheBackend()
     storageCls = cls.__CACHE_STORAGE_LIST.get(backend,
                                               cls.__CACHE_STORAGE_DEFAULT)
     return storageCls(*args, **kwargs)
Exemplo n.º 34
0
 def __init__(self):
     self._stylesheets = Config.getInstance().getStylesheets()
     self._eventStylesheets = Config.getInstance().getEventStylesheets()
     self._defaultEventStylesheet = Config.getInstance(
     ).getDefaultEventStylesheet()
Exemplo n.º 35
0
 def recover(self):
     self.smtpServer = Config.getInstance().getSmtpServer()
     TrashCanManager().remove(self)
Exemplo n.º 36
0
 def getStyles(self):
     try:
         return self._styles
     except AttributeError:
         self._styles = Config.getInstance().getStyles()
         return self._styles
Exemplo n.º 37
0
 def _connect(self):
     client = redis.StrictRedis.from_url(Config.getInstance().getRedisCacheURL())
     client.connection_pool.connection_kwargs['socket_timeout'] = 1
     return client
Exemplo n.º 38
0
 def getPublicSupportEmail(self):
     if not hasattr(self, "_publicSupportEmail") or (
         self._publicSupportEmail == "" and Config.getInstance().getPublicSupportEmail() != ""
     ):
         self._publicSupportEmail = Config.getInstance().getPublicSupportEmail()
     return self._publicSupportEmail
Exemplo n.º 39
0
 def _connect(self):
     import memcache
     return memcache.Client(Config.getInstance().getMemcachedServers())