Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _doGetPhotoId(self, force=False):
photoId = "%s-%s-%s-%s" % (str(self._getSafeLocationName()), str(self.building).strip(), str(self.floor).strip(), str(self.roomNr).strip())
filePath = Config.getInstance().getRoomPhotosDir()
fileName = photoId + ".jpg"
fullPath = os.path.join(filePath, fileName)
from os.path import exists
if exists(fullPath) or force:
return photoId
else:
return None
AbstractStatusDuplicated, AbstractStatusMerged, AbstractAcceptance, AbstractRejection,\
AbstractReallocation, NotifTplCondAccepted
from MaKaC.conference import AccessController, LocalFile, Link, Paper, Slides,\
Video, Poster, Minutes, Material, SubContribParticipation, SubContribution,\
ContributionType, ContributionParticipation, Contribution, AcceptedContribution,\
SessionSlot, Session, Conference, ContribStatusWithdrawn, ContribStatusNotSch,\
ContribSchEntry
from MaKaC.schedule import BreakTimeSchEntry
from MaKaC.trashCan import TrashCanManager
from MaKaC.user import AvatarHolder
from MaKaC.participant import Participant
from MaKaC.domain import DomainHolder
from MaKaC.webinterface import displayMgr
# The folder that contains the current database file.
currentPath = Config.getInstance().getCurrentDBDir()
# The folder that contains the database backups.
backupsPath = Config.getInstance().getDBBackupsDir()
# The folder that contains temporary database files.
tmpPath = Config.getInstance().getTempDir()
# Name of the database file.
dataFile = "data.fs"
python = os.path.join(sysconfig.get_config_vars()["exec_prefix"], "python")
## TO BE CHANGED:
repozo = "/usr/bin/repozo.py"
def incPrintPrefix(pp):
# pp is a print prefix that is used to display the output messages in a
elif not alarm.startDateTime:
print cformat('%{red!}!!!%{reset} '
'%{white!}{:6s}%{reset} %{yellow!}Alarm has no start time').format(event.id)
continue
start_dt = self._dt_with_tz(alarm.startDateTime).replace(second=0, microsecond=0)
if not hasattr(alarm, 'status'):
# Those ancient alarms can be safely assumed to be sent
is_sent = True
else:
is_sent = alarm.status not in {1, 2} # not spooled/queued
is_overdue = False
if not is_sent and start_dt < sent_threshold:
is_sent = True
is_overdue = True
recipients = filter(None, {convert_to_unicode(x).strip().lower() for x in alarm.toAddr})
reminder = EventReminder(event_id=int(event.id), creator_id=Config.getInstance().getJanitorUserId(),
created_dt=alarm.createdOn, scheduled_dt=start_dt, is_sent=is_sent,
event_start_delta=getattr(alarm, '_relative', None), recipients=recipients,
send_to_participants=alarm.toAllParticipants,
include_summary=alarm.confSumary,
reply_to_address=convert_to_unicode(alarm.fromAddr).strip().lower(),
message=convert_to_unicode(alarm.note).strip())
db.session.add(reminder)
status = (cformat('%{red!}OVERDUE%{reset}') if is_overdue else
cformat('%{green!}SENT%{reset}') if is_sent else
cformat('%{yellow}PENDING%{reset}'))
print cformat('%{green}+++%{reset} '
'%{white!}{:6s}%{reset} %{cyan}{}%{reset} {}').format(event.id, reminder.scheduled_dt, status)
vars["statusText"] = _("ACCEPTED")
vars["statusClass"] = "contributionReviewingStatusAccepted"
elif statusReviewing == "Reject":
vars["statusText"] = _("REJECTED")
vars["statusClass"] = "contributionReviewingStatusRejected"
elif statusReviewing == "To be corrected":
vars["statusText"] = _("To be corrected")
vars["statusClass"] = "contributionReviewingStatusCorrected"
elif statusReviewing is not None:
vars["statusText"] = statusReviewing
vars["statusClass"] = "contributionReviewingStatusCorrected"
else:
vars["statusText"] = _("Paper not yet submitted")
vars["statusClass"] = "contributionReviewingStatusNotSubmitted"
vars["prefixUpload"] = "Re-" if statusReviewing not in ["Accept", "Reject", None] else ""
vars["reportNumberSystems"] = Config.getInstance().getReportNumberSystems()
return vars
def _getIconURL(cls,statusId):
return Config.getInstance().getSystemIconURL(cls._statusProps.get(statusId,["","",""])[1])
else:
pdil = ["Name"]
self._groupsorder = {"PersonalData": pdil} # list used to display the info of the registrants in the same order
for key in display:
if key == "Id" or not columns.has_key(key):
continue
url = self._getURL()
url.addParam("sortBy", key)
img = ""
if currentSorting == key:
currentSortingHTML = """<input value="%s" name="sortBy" type="hidden">""" % key
if self._order == "down":
img = """<img alt="down" src="%s">""" % (quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
url.addParam("order", "up")
elif self._order == "up":
img = """<img alt="up" src="%s">""" % (quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
url.addParam("order", "down")
sortingURL = quoteattr("%s#results" % str(url))
kg = self._getKeyDispOpts(key)
if not resgroups.has_key(kg):
self._groupsorder[kg] = []
resgroups[kg] = []
self._groupsorder[kg].append(key)
resgroups[kg].append("""%s<a href="%s">%s</a>"""%(img, sortingURL, self.htmlText(columns[key].replace('<span style="color:red;font-size: 75%">(disabled)</span>',''))))
fields = ["""
"""]
# First we want to display the personal data...
groupkey = "PersonalData"
fields += resgroups[groupkey]
del resgroups[groupkey]
#...and them all the other info:
def __init__(self, task):
GenericNotification.__init__(self)
self.setFromAddr("Indico <%s>" % Config.getInstance().getNoReplyEmail())
self.setToList([task.avatar.getEmail()])
self.setSubject("""
The offline version of the event "%s" is ready to be downloaded
""" % (task.conference.getTitle()))
self.setBody("""
Dear %s,
The offline version for the event "%s" was successfully generated and it is ready to be downloaded.
Download link: %s
Best Regards,
--
Indico""" % (task.avatar.getStraightFullName(), task.conference.getTitle(), task.getDownloadLink()))
def migrate_chatrooms(self):
print cformat('%{white!}migrating chatrooms')
default_server = ChatPlugin.settings.get('muc_server')
chatrooms = {}
for old_room in committing_iterator(self.chat_root['indexByID']._data.itervalues()):
has_custom_server = not old_room._createdInLocalServer and old_room._host != default_server
custom_server = convert_to_unicode(old_room._host) if has_custom_server else ''
identifier = (custom_server, old_room._name.lower())
room = chatrooms.get(identifier)
if room:
print cformat('- %{cyan}{} %{yellow!}DUPLICATE%{reset}').format(room.name)
else:
user = User.get(int(old_room._owner.id)) or User.get(Config.getInstance().getJanitorUserId())
room = Chatroom(jid_node=convert_to_unicode(old_room._name.lower()),
name=convert_to_unicode(old_room._name),
description=convert_to_unicode(old_room._description),
password=convert_to_unicode(old_room._password),
custom_server=custom_server,
created_by_user=user,
created_dt=old_room._creationDate,
modified_dt=old_room._modificationDate)
chatrooms[identifier] = room
db.session.add(room)
print cformat('- %{cyan}{}').format(room.name)
if room.custom_server:
print cformat(' %{blue!}Custom server:%{reset} {}').format(room.custom_server)
events = set()
for event in old_room._conferences:
def _getNewTempFile( self ):
cfg = Config.getInstance()
tempPath = cfg.getUploadedFilesTempDir()
tempFileName = tempfile.mkstemp( suffix="Indico.tmp", dir = tempPath )[1]
return tempFileName