Changeset 0cb016 in indico
- Timestamp:
- 06/10/10 18:11:38 (3 years ago)
- Branches:
- master, burotel, hello-world-walkthrough, ipv6, new-webex, v0.97-series, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 0da0c1403bae8e51d8229f460181c71b9e6dda72
- Children:
- 2349da
- Parents:
- 18bdc4
- git-author:
- Jeremy Herr <jeremy.herr@…> (05/06/10 18:33:15)
- git-committer:
- Jeremy Herr <jeremy.herr@…> (06/10/10 18:11:38)
- Location:
- indico/MaKaC
- Files:
-
- 3 added
- 6 edited
-
plugins/Collaboration/RecordingManager/common.py (modified) (8 diffs)
-
plugins/Collaboration/RecordingManager/options.py (modified) (1 diff)
-
plugins/Collaboration/RecordingManager/services.py (modified) (6 diffs)
-
plugins/Collaboration/RecordingManager/tpls/Extra.js (modified) (2 diffs)
-
plugins/Collaboration/RecordingManager/tpls/NewBookingForm.tpl (modified) (1 diff)
-
webinterface/stylesheets/micala_lecture_conference.xsl (modified) (1 diff)
-
webinterface/stylesheets/micala_lecture_contribution.xsl (added)
-
webinterface/stylesheets/micala_lecture_session.xsl (added)
-
webinterface/stylesheets/micala_lecture_subcontribution.xsl (added)
Legend:
- Unmodified
- Added
- Removed
-
indico/MaKaC/plugins/Collaboration/RecordingManager/common.py
r18bdc4 r0cb016 383 383 a conference, subcontribution etc, and return that info with the individual IDs.""" 384 384 385 # regular expressions to match IndicoIDs for conference, session, contribution, subcontribution 385 386 pConference = re.compile('(\d+)$') 386 387 pSession = re.compile('(\d+)s(\d+)$') … … 388 389 pSubcontribution = re.compile('(\d+)c(\d+)sc(\d+)$') 389 390 391 # perform the matches (match searches from the beginning of the string, 392 # unlike search, which matches anywhere in the string) 390 393 mE = pConference.match(IndicoID) 391 394 mS = pSession.match(IndicoID) … … 393 396 mSC = pSubcontribution.match(IndicoID) 394 397 398 # Depending on which talk type it is, populate a dictionary containing the name of 399 # the type of talk, the actual object, and the individual conference, session, contribution, 400 # subcontribution IDs. 395 401 if mE: 396 402 Logger.get('RecMan').debug("searched %s, matched %s" % (IndicoID, 'conference')) … … 472 478 # Defining the dictionary 'tags' is how we identify ourselves to the outputGenerator 473 479 # methods. 480 # Call ConfToXML with different args depending on talk type. 481 # includeSession - descend into each session. 482 # This is necessary for sessions, contributions, and subcontributions, 483 # since contributions and subcontributions are children of sessions. 484 # includeContribution - necessary for contributions and subcontributions 485 # includeMaterial - this is always set to "1". 486 # showSession - create XML for a particular session, identified by ID 487 # showContribution - create XML for a particular contribution, identified by ID 488 # showSubContribution - create XML for a particular subcontribution, identified by ID 489 # forceCache - True means force it NOT to use the cache, the opposite of what you would expect. 490 # recordingManagerTags - this is how we pass along all the necessary RecordingManager args to the outputGenerator methods. 491 # 474 492 # Nobody outside CERN should have access to CERN access lists. 475 493 # OAI harvesters outside CERN call the same methods we'll be calling, … … 524 542 xmlGen.closeTag("event") 525 543 526 # Get base XML544 # Retrieve the entire basic XML string 527 545 return xmlGen.getXml() 528 546 … … 629 647 except Exception, e: 630 648 flagSuccess = False 631 result += "Unknown error occured when updating task information in micala database: %s\n." % e649 result += _("Unknown error occured when updating task information in micala database: ") + e + "\n" 632 650 633 651 return {"success": flagSuccess, "result": result} 634 652 635 def submitMicalaMetadata(aw, IndicoID, contentType, videoFormat, languages):653 def submitMicalaMetadata(aw, IndicoID, contentType, LOID, videoFormat, languages): 636 654 '''Generate a lecture.xml file for the given event, then web upload it to the micala server.''' 637 655 638 basexml = getBasicXMLRepresentation(aw, IndicoID, contentType, videoFormat, languages) 639 640 from MaKaC.common import Config 641 642 micalaxml = "" 643 644 # Given the IndicoID, retrieve the type of talk and IDs, so we know which XSL file to use. 645 parsed = parseIndicoID(IndicoID) 646 647 # Choose the appropriate stylesheet: 648 # - micala_lecture_conference.xsl 649 # - micala_lecture_session.xsl 650 # - micala_lecture_contribution.xsl 651 # - micala_lecture_subcontribution.xsl 652 styleSheet = "%s_%s.xsl" % ('cds_marcxml_video', parsed["type"]) 653 stylePath = os.path.join(Config.getInstance().getStylesheetsDir(), styleSheet) 654 655 if os.path.exists(stylePath): 656 try: 657 Logger.get('RecMan').info("Trying to do XSLT using path %s" % stylePath) 658 parser = XSLTransformer(stylePath) 659 micalaxml = parser.process(basexml) 660 except Exception: 661 micalaxml = "Cannot parse stylesheet: %s" % sys.exc_info()[0] 662 else: 663 micalaxml = basexml 656 Logger.get('RecMan').debug('in submitMicalaMetadata()') 657 658 # Initialize success flag, and result string to which we will append any errors. 659 flagSuccess = True 660 result = "" 661 662 # First, update the micala Tasks table that the submission has started 664 663 665 664 # pattern to match for the signal file … … 674 673 675 674 # Update the micala database with our current task status 676 idMachine = MicalaCommunication.getIdMachine(CollaborationTools.getOptionValue("RecordingManager", "micalaDBMachineName")) 677 idTask = MicalaCommunication.getIdTask(CollaborationTools.getOptionValue("RecordingManager", "micalaDBStatusExportCDS")) 678 idLecture = MicalaCommunication.getIdLecture(IndicoID, pattern_cern, pattern_umich) 679 if idLecture == '': 680 idLecture = MicalaCommunication.createNewMicalaLecture(IndicoID, contentType, pattern_cern, pattern_umich) 681 MicalaCommunication.reportStatus('START', '', idMachine, idTask, idLecture) 675 try: 676 Logger.get('RecMan').debug('calling getIdMachine...') 677 idMachine = MicalaCommunication.getIdMachine(CollaborationTools.getOptionValue("RecordingManager", "micalaDBMachineName")) 678 Logger.get('RecMan').debug('calling getIdTask...') 679 idTask = MicalaCommunication.getIdTask(CollaborationTools.getOptionValue("RecordingManager", "micalaDBStatusExportMicala")) 680 Logger.get('RecMan').debug('calling getIdLecture...') 681 idLecture = MicalaCommunication.getIdLecture(IndicoID, pattern_cern, pattern_umich) 682 Logger.get('RecMan').debug('calling reportStatus...') 683 if idLecture == '': 684 idLecture = MicalaCommunication.createNewMicalaLecture(IndicoID, contentType, pattern_cern, pattern_umich) 685 MicalaCommunication.reportStatus('START', '', idMachine, idTask, idLecture) 686 except Exception, e: 687 flagSuccess = False 688 result += _("Unknown error occured when updating MICALA START task information in micala database: %s\n." % e) 689 690 basexml = getBasicXMLRepresentation(aw, IndicoID, contentType, videoFormat, languages) 691 692 from MaKaC.common import Config 693 694 micalaxml = "" 695 696 # Given the IndicoID, retrieve the type of talk and IDs, so we know which XSL file to use. 697 parsed = parseIndicoID(IndicoID) 698 699 # Choose the appropriate stylesheet: 700 # - micala_lecture_conference.xsl 701 # - micala_lecture_session.xsl 702 # - micala_lecture_contribution.xsl 703 # - micala_lecture_subcontribution.xsl 704 styleSheet = "%s_%s.xsl" % ('micala_lecture', parsed["type"]) 705 stylePath = os.path.join(Config.getInstance().getStylesheetsDir(), styleSheet) 706 707 if os.path.exists(stylePath): 708 try: 709 Logger.get('RecMan').info("Trying to do XSLT using path %s" % stylePath) 710 parser = XSLTransformer(stylePath) 711 micalaxml = parser.process(basexml) 712 except Exception, e: 713 flagSuccess = False 714 result += "Cannot parse stylesheet: %s" % sys.exc_info()[0] 715 else: 716 flagSuccess = False 717 result += "Stylesheet does not exist: %s" % stylePath 682 718 683 719 # temporary, for my own debugging 684 f = open('/tmp/ lecture.xml', 'w')720 f = open('/tmp/micala.xml', 'w') 685 721 f.write(micalaxml) 686 722 f.close() 687 723 688 # Submit XML record to micala server 689 data = urlencode({ 690 "file": micalaxml, 691 "mode": "-ir" 692 }) 724 # Web upload metadata to micala server 725 if flagSuccess == True: 726 # encode the LOID and the XML file as POST variables 727 data = urlencode({ "LOID": LOID, "micalaxml": micalaxml }) 728 # use the header to identify ourselves 729 headers = {"User-Agent": "micala_webupload"} 730 # build the request 731 request = Request(CollaborationTools.getOptionValue("RecordingManager", "micalaUploadURL"), data, headers) 732 733 Logger.get('RecMan').debug("micala request = %s" % str(request)) 734 735 # submit the request, and append caught exceptions to the result string, 736 # to be displayed by services.py 737 try: 738 f = urlopen(request) 739 request_result = f.read() 740 if request_result == 'no data': 741 result += _("micala web upload returned an unknown error when submitting to ") + "%s\n" % \ 742 (CollaborationTools.getOptionValue("RecordingManager", "micalaUploadURL")) 743 Logger.get('RecMan').debug("micala result = %s" % str(request_result)) 744 except HTTPError, e: 745 flagSuccess = False 746 result += _("micala web upload returned an error when submitting to ") + "%s: %s\n" % \ 747 (CollaborationTools.getOptionValue("RecordingManager", "micalaUploadURL"), e) 748 except Exception, e: 749 flagSuccess = False 750 result += _("Unknown error occured when submitting micala metadata: ") + e + "\n" 751 752 # Update the micala database showing the task has started, but only if 753 # the submission actually succeeded. 754 if flagSuccess == True: 755 # pattern to match for the signal file 756 # Here we are looking for 757 # CONFID 758 # or CONFIDcCONTRID 759 # or CONFIDcCONTRIDscSCONTRID 760 # or CONFIDsSESSID 761 pattern_cern = re.compile('([sc\d]+)$') 762 # Here we are looking for YYYYMMDD-DEVICENAME-HHMMSS 763 pattern_umich = re.compile('(\d+\-[\w\d]+\-\d)$') 764 765 # Update the micala database with our current task status 766 try: 767 if idLecture == '': 768 idLecture = MicalaCommunication.createNewMicalaLecture(IndicoID, contentType, pattern_cern, pattern_umich) 769 MicalaCommunication.reportStatus('COMPLETE', '', idMachine, idTask, idLecture) 770 except Exception, e: 771 flagSuccess = False 772 result += _("Unknown error occured when updating COMPLETE MICALA task information in micala database: %s\n." % e) 773 774 return {"success": flagSuccess, "result": result} 693 775 694 776 def getCDSRecords(confId): … … 706 788 # if this CDS query needs to be changed (thanks jerome.caffaro@cern.ch): 707 789 # http://invenio-demo.cern.ch/help/hacking/search-engine-api 708 # NB: We replace the string INDICO_ID manually instead of using %s because790 # NB: We replace the string REPLACE_WITH_INDICO_ID manually instead of using %s because 709 791 # there are also url-encoded chars containing the % char. 710 792 optionsCDSQueryURL = CollaborationTools.getOptionValue("RecordingManager", "CDSQueryURL") 711 793 escapedOptionsCDSQueryURL = optionsCDSQueryURL.replace("REPLACE_WITH_INDICO_ID", id_plus_wildcard) 712 Logger.get('RecMan').debug("optionsCDSQueryURL = " + optionsCDSQueryURL)713 794 Logger.get('RecMan').debug("escapedOptionsCDSQueryURL = " + escapedOptionsCDSQueryURL) 714 795 url = escapedOptionsCDSQueryURL -
indico/MaKaC/plugins/Collaboration/RecordingManager/options.py
r18bdc4 r0cb016 113 113 "visible": True} ), 114 114 115 ("micalaUploadURL", {"description" : _("URL for micala web upload"), 116 "type": str, 117 "defaultValue": "http://lectureprocessing01.cern.ch/micala_monitor/test.py", 118 "editable": True, 119 "visible": True} ), 120 115 121 ("CDSQueryURL", {"description" : _("CDS query URL (put the string REPLACE_WITH_INDICO_ID where you want the Indico ID to be)"), 116 122 "type": str, -
indico/MaKaC/plugins/Collaboration/RecordingManager/services.py
r5f9652 r0cb016 22 22 from MaKaC.services.implementation.collaboration import CollaborationPluginServiceBase 23 23 from MaKaC.plugins.Collaboration.RecordingManager.exceptions import RecordingManagerException 24 from MaKaC.plugins.Collaboration.RecordingManager.common import createIndicoLink, createCDSRecord 24 from MaKaC.plugins.Collaboration.RecordingManager.common import createIndicoLink, createCDSRecord, submitMicalaMetadata 25 25 from MaKaC.plugins.Collaboration.RecordingManager.micala import MicalaCommunication 26 26 … … 48 48 self._IndicoID = self._params.get('IndicoID', None) 49 49 self._LOID = self._params.get('LOID', None) 50 self._LODBID = self._params.get('LODBID', None) 50 51 self._confId = self._params.get('conference', None) 51 52 self._videoFormat = self._params.get('videoFormat', None) … … 59 60 60 61 if self._contentType == 'web_lecture': 61 if not self._LO ID:62 raise RecordingManagerException("No LO ID supplied")62 if not self._LODBID: 63 raise RecordingManagerException("No LODBID supplied") 63 64 elif self._contentType == 'plain_video': 64 65 if not self._videoFormat: … … 72 73 73 74 def _getAnswer(self): 74 # Get the MARC XML and submit it to CDS 75 # Get the MARC XML and submit it to CDS, 76 # then update micala database Status table showing task completed 75 77 resultCreateCDSRecord = createCDSRecord(self._aw, 76 78 self._IndicoID, … … 83 85 return "CDS record creation aborted." 84 86 85 # Update the micala database 87 # Create lecture.xml and submit to micala server, 88 # then update micala database Status table showing task completed 89 # (this only makes sense if it is a web lecture) 90 if self._contentType == 'web_lecture': 91 resultSubmitMicalaMetadata = submitMicalaMetadata(self._aw, 92 self._IndicoID, 93 self._contentType, 94 self._params.get('LOID', None), 95 self._videoFormat, 96 self._languages) 97 98 if resultSubmitMicalaMetadata["success"] == False: 99 raise RecordingManagerException("CDS record creation failed.\n%s" % resultSubmitMicalaMetadata["result"]) 100 return "micala metadata creation aborted." 101 102 # Update the micala database to match the LODBID with the IndicoID 103 # This only makes sense for web lectures, so if contentType is plain_video, 104 # this method does nothing. 86 105 resultUpdateMicala = MicalaCommunication.updateMicala(self._IndicoID, 87 106 self._contentType, 88 self._params.get('LO ID', None))107 self._params.get('LODBID', None)) 89 108 90 109 if resultUpdateMicala["success"] == False: … … 100 119 CollaborationPluginServiceBase._checkParams(self) #puts the Conference in self._conf 101 120 self._IndicoID = self._params.get('IndicoID', None) 102 self._LOID = self._params.get('LOID', None)103 121 self._confId = self._params.get('conference', None) 104 122 self._CDSID = self._params.get('CDSID', None) -
indico/MaKaC/plugins/Collaboration/RecordingManager/tpls/Extra.js
r18bdc4 r0cb016 459 459 conference: '<%= ConferenceId %>', 460 460 IndicoID: RMselectedTalkId, 461 LOID: RMselectedLODBID, 461 LOID: RMLOList[RMselectedLODBID]["LOID"], 462 LODBID: RMselectedLODBID, 462 463 videoFormat: RMvideoFormat, 463 464 contentType: RMviewMode, … … 505 506 conference: '<%= ConferenceId %>', 506 507 IndicoID: RMselectedTalkId, 507 LOID: RMselectedLODBID,508 508 CDSID: RMTalkList[RMselectedTalkId]["CDSID"] 509 509 }, -
indico/MaKaC/plugins/Collaboration/RecordingManager/tpls/NewBookingForm.tpl
r18bdc4 r0cb016 221 221 222 222 // Pass the metadata we need for each talk to JavaScript 223 // replacing any double-quotes " with the encoded char %22, 224 // (otherwise any quotes in the title will cause a JavaScript error) 223 225 var RMTalkList = { 224 226 <% for talk in Talks: %> 225 227 "<%= talk["IndicoID"] %>": { 226 "title": "<%= talk["title"] %>",227 "titleshort": "<%= talk["titleshort"] %>",228 "type": "<%= talk["type"] %>",229 "CDSID": "<%= talk["CDSID"] %>",230 "CDSURL": "<%= talk["CDSURL"] %>",231 "type": "<%= talk["type"] %>",232 "speakers": "<%= talk["speakers"] %>",233 "date": "<%= talk["date"] %>",234 "date_nice": "<%= talk["date_nice"] %>",235 "LOID": "<%= talk["LOID"] %>",236 "IndicoLink": "<%= talk["IndicoLink"] %>"228 "title": "<%= talk["title"].replace('"', '%22') %>", 229 "titleshort": "<%= talk["titleshort"].replace('"', '%22') %>", 230 "type": "<%= talk["type"] %>", 231 "CDSID": "<%= talk["CDSID"] %>", 232 "CDSURL": "<%= talk["CDSURL"] %>", 233 "type": "<%= talk["type"] %>", 234 "speakers": "<%= talk["speakers"] %>", 235 "date": "<%= talk["date"] %>", 236 "date_nice": "<%= talk["date_nice"] %>", 237 "LOID": "<%= talk["LOID"] %>", 238 "IndicoLink": "<%= talk["IndicoLink"] %>" 237 239 }, 238 240 <% end %> -
indico/MaKaC/webinterface/stylesheets/micala_lecture_conference.xsl
r5f9652 r0cb016 25 25 <xsl:template match="event"> 26 26 27 <!DOCTYPE LECTURE SYSTEM "http://www.wlap.org/dtd/lecture.dtd"> 28 <LECTURE TITLE="<xsl:value-of select="./title"/>"> 29 <xsl:for-each select="./chair/user"> 30 <AUTHOR><xsl:apply-templates select="./name"/></AUTHOR> 31 </xsl:for-each> 32 <DATE><xsl:value-of select="./startDate" disable-output-escaping="yes"/></DATE> 33 <LANGUAGE> 34 <xsl:choose> 35 <xsl:when test="./languages != ''"> 36 <xsl:for-each select="./languages/code"> 37 <LANGUAGE><xsl:value-of select="." /></LANGUAGE> 38 </xsl:for-each> 39 </xsl:when> 40 <xsl:otherwise> 41 <LANGUAGE>eng</LANGUAGE> 42 </xsl:otherwise> 43 </xsl:choose> 44 </LANGUAGE> 45 <DURATION><xsl:value-of select="./duration"/></DURATION> 46 <TIME><xsl:value-of select="./startDate" disable-output-escaping="yes"/></TIME> 47 <PAR> 48 <VIDEO REGION="speaker-face"> 49 <SWITCH> 50 <REF SRC="media/master.flv" TYPE="video/flash" WIDTH="240" HEIGHT="160" AUDIO="Yes" VIDEO="Yes" AVERAGERATE="" ADAPTIVE="No"/> 51 </SWITCH> 52 </VIDEO> 53 <SEQ TITLE="Sequence of slides" REGION="slide" > 54 </SEQ> 55 </PAR> 27 <!-- <!DOCTYPE LECTURE SYSTEM "http://www.wlap.org/dtd/lecture.dtd"> --> 28 <LECTURE> 29 <TITLE><xsl:value-of select="./title" /></TITLE> 30 <xsl:for-each select="./chair/user"> 31 <AUTHOR><xsl:apply-templates select="./name"/></AUTHOR> 32 </xsl:for-each> 33 <DATE><xsl:value-of select="substring(./startDate, 0, 11)" /></DATE> 34 <LANGUAGE> 35 <xsl:choose> 36 <xsl:when test="./languages != ''"> 37 <xsl:for-each select="./languages/code"> 38 <xsl:value-of select="." /> 39 </xsl:for-each> 40 </xsl:when> 41 <xsl:otherwise> 42 <LANGUAGE>eng</LANGUAGE> 43 </xsl:otherwise> 44 </xsl:choose> 45 </LANGUAGE> 46 <DURATION><xsl:value-of select="./duration"/></DURATION> 47 <TIME><xsl:value-of select="substring(./startDate, 12, 8)" disable-output-escaping="yes"/></TIME> 48 <PAR> 49 <VIDEO REGION="speaker-face"> 50 <SWITCH> 51 <REF SRC="media/master.flv" TYPE="video/flash" WIDTH="240" HEIGHT="160" AUDIO="Yes" VIDEO="Yes" AVERAGERATE="" ADAPTIVE="No"/> 52 </SWITCH> 53 </VIDEO> 54 <SEQ TITLE="Sequence of slides" REGION="slide" > 55 <SLIDE TYPE="DUMMY" /> 56 </SEQ> 57 </PAR> 56 58 </LECTURE> 59 60 </xsl:template> 61 62 <xsl:template match="name"> 63 <xsl:value-of select="./@last" disable-output-escaping="yes"/> 64 <xsl:if test="./@first!='' and ./@last!=''"> 65 <xsl:text disable-output-escaping="yes">, </xsl:text> 66 </xsl:if> 67 <xsl:value-of select="./@first" disable-output-escaping="yes"/> 68 </xsl:template> 69 70 </xsl:stylesheet>
Note: See TracChangeset
for help on using the changeset viewer.
