Changeset 1572 for WAeUP_SRP/trunk


Ignore:
Timestamp:
17 Mar 2007, 15:58:54 (18 years ago)
Author:
Henrik Bettermann
Message:

Uli's new log file viewer

Location:
WAeUP_SRP/trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/WAeUPTool.py

    r1571 r1572  
    478478    ###)
    479479
     480    security.declareProtected(ModifyPortalContent,'getLogfileLines') ###(
     481    def getLogfileLines(self,filename="event.log",numlines=20):
     482        """Get last NUMLINES lines of logfile FILENAME.
     483
     484        Return last lines' of a file in the instances logfile directory as
     485        a list. The number of returned lines equals `numlines' or less. If
     486        less than `numlines' lines are available, the whole file ist
     487        returned. If the file can not be opened or some other error
     488        occurs, empty list is returend.
     489        """
     490        result = []
     491        lines_hit = 0
     492
     493        # We only handle files in instances' log directory...
     494        logpath = os.path.join(i_home, "log")
     495        filename = str(os.path.abspath( os.path.join( logpath, filename )))
     496        if not filename.startswith( logpath ):
     497            # Attempt to access file outside log-dir...
     498            return []
     499
     500        try:
     501            fd = file( filename, "rb" )
     502        except IOError:
     503            return []
     504        if not fd:
     505            return []
     506
     507        if os.linesep == None:
     508            linesep = '\n'
     509        else:
     510            linesep = os.linesep
     511
     512        # Try to find 'numlines' times a lineseparator, searching from end
     513        # and moving to the beginning of file...
     514        fd.seek( 0, 2) # Move to end of file...
     515        while lines_hit < numlines:
     516            if fd.read(1) == linesep[-1]: # This moves filedescriptor
     517                                          # one step forward...
     518                lines_hit += 1
     519            try:
     520                fd.seek( -2, 1) # Go two bytes back from current pos...
     521            except IOError:
     522                # We cannot go back two bytes. Maybe the file is too small...
     523                break
     524        fd.seek(2,1)
     525
     526        # Read all lines from current position...
     527        result = fd.readlines()
     528        # Remove line endings...
     529        result = [x.strip() for x in result]
     530        fd.close()
     531        return result
     532    ###)
    480533
    481534InitializeClass(WAeUPTool)
  • WAeUP_SRP/trunk/skins/waeup_student/search_students_form.pt

    r1568 r1572  
    2727      <nobr><a href="statistics_reg_view">Registration Statistics</a>
    2828      &nbsp;&nbsp;&nbsp;&nbsp;</nobr>       
     29      <nobr><a href="list_students">Cleared Student Export</a>
     30      &nbsp;&nbsp;&nbsp;&nbsp;</nobr>
    2931      <span tal:condition="is_so">
    30          <nobr><a href="list_students">Cleared Student Export</a>
     32         <nobr><a href="view_logs">View Log Files</a>
    3133         &nbsp;&nbsp;&nbsp;&nbsp;</nobr>
    32          <nobr><a href="paid_transfer_list">Transfer Student Export</a></nobr>   
    33          &nbsp;&nbsp;&nbsp;&nbsp;
    34          <nobr><a href="add_student">Add Student Record</a></nobr>
     34         <nobr><a href="add_student">Add Student Record</a>       
     35         &nbsp;&nbsp;&nbsp;&nbsp;</nobr>
     36         <nobr><a href="paid_transfer_list">Export Transfer Students</a></nobr>   
    3537      </span>
    3638      </strong>
     39   
     40             
    3741        <h3> Search Student Section</h3><br />
    3842          You are logged in as member <span tal:replace="info/member|nothing" />
     
    4246          </span>
    4347          <span tal:condition="info/departments|nothing" tal:omit-tag="">
    44             and <span tal:repeat="department info/departments|nothing" tal:content="department"/></span>
    45           <span tal:condition="info/certificate_level|nothing" tal:omit-tag="">
    46             who is CourseAdviser for
    47             <span tal:repeat="cl info/certificate_level" tal:content="cl" />
    48           </span>.
     48            and <span tal:repeat="department info/departments|nothing" tal:content="department"/></span>.
    4949          <br /><br />
    5050        <span tal:replace="structure rendered" />
  • WAeUP_SRP/trunk/skins/waeup_student/students_index.py

    r1557 r1572  
    2525if "ClearanceOfficers" in member.getGroups() or\
    2626   "CourseAdvisers" in member.getGroups():
    27     return redirect("%s/search_students" % context.portal_url())
     27    return redirect("%s/campus/search_students" % context.portal_url())
    2828if context.isSectionOfficer():
    29     return redirect("%s/search_students" % context.portal_url())
     29    return redirect("%s/campus/search_students" % context.portal_url())
    3030if context.isStudent():
    3131    id = str(member)
Note: See TracChangeset for help on using the changeset viewer.