コード例 #1
0
ファイル: generate.py プロジェクト: RREYESAL/RPC_HVScan
def main():
    options = {
        'outputDirectory': defaultOutputDirectory,
    }

    # Generate all the docs
    mdwn = markdown.Markdown(safe_mode = 'escape', extensions = ['headerid'])

    documentsList = ''
    inputFilenameRE = re.compile('^(.*)\.mdwn$')
    titleRE = re.compile('^# (.*)$', re.MULTILINE)
    sectionsRE = re.compile('^<h2 id="(.*)">(.*)</h2>$', re.MULTILINE)

    for inputFilename in sorted(os.listdir('.')):
        match = inputFilenameRE.match(inputFilename)
        if not match:
            continue

        outputName = match.groups()[0]
        outputFilename = os.path.join(options['outputDirectory'], outputName + '.html')

        logging.info('Generating: ' + outputFilename + ' from ' + inputFilename)

        fd = open(inputFilename, 'r')
        inputText = fd.read()
        fd.close()

        # If there is a line starting with # (i.e. <h1>), use it as the title.
        # Otherwise default to the outputName.
        title = outputName
        match = titleRE.search(inputText)
        if match:
            title = match.groups()[0]

        bodyText = mdwn.convert(inputText)

        # Search for sections (i.e. ##, <h2>) and build the index with them.
        # This is done after convert() because the headerid extension generates IDs for us automatically.
        index = None
        match = sectionsRE.search(bodyText)
        if match:
            index = '<h2>Index</h2><ol>'
            for section in sectionsRE.findall(bodyText):
                index += '<li><a href="#%s">%s</a></li>' % section
            index += '</ol>'

            # Put the index just before the first section
            # (so that the "abstract" or "introduction" is kept
            # after the title but before the index)
            firstSection = bodyText.find('<h2')
            bodyText = bodyText[:firstSection] + index + bodyText[firstSection:]

        outputText = docsTemplate.render(title = title, body = bodyText)

        write(outputFilename, outputText)

        # Add the doc to the global index
        documentsList += '<li><a href="%s">%s</a></li>' % (outputName + '.html', title)

    # Generate a simple docs' index (i.e. a list of the files)
    outputFilename = os.path.join(options['outputDirectory'], indexFilename)
    logging.info('Generating: ' + outputFilename)

    developmentMailingList = read('developmentMailingList.txt')
    gitWeb = read('gitWeb.txt')
    jiraWeb = read('jiraWeb.txt')

    servicesList = ''
    for service in config.getServicesList():
        servicesList += '<li><a href="/%s/">%s</a></li>' % (service, service)

    bodyText = '''
        <h1>%s</h1>
        <p>Services:</p><ul>%s</ul>
        <p>Development mailing list (you need to be subscribed):</p><ul><li><a href="mailto:%s">%s</a></li></ul>
        <p>Git web:</p><ul><li><a href="%s">%s</a></li></ul>
        <p>JIRA web:</p><ul><li><a href="%s">%s</a></li></ul>
        <p>Documents:</p><ul>%s</ul>
        <p>If it is your first time, please start by reading Developing.</p>
    ''' % (indexTitle, servicesList, developmentMailingList, developmentMailingList, gitWeb, gitWeb, jiraWeb, jiraWeb, documentsList)

    outputText = docsTemplate.render(title = indexTitle, body = bodyText)
    write(outputFilename, outputText)
コード例 #2
0
ファイル: keeper.py プロジェクト: lchaparr/ThesisCode
#!/usr/bin/env python2.6
'''Keeper of the CMS DB Web services.
'''

__author__ = 'Miguel Ojeda'
__copyright__ = 'Copyright 2012, CERN CMS'
__credits__ = ['Miguel Ojeda', 'Andreas Pfeiffer']
__license__ = 'Unknown'
__maintainer__ = 'Miguel Ojeda'
__email__ = '*****@*****.**'

import config

services = config.getServicesList(showHiddenServices=True)

import os
import glob
import subprocess
import sys
import signal
import time
import smtplib
import email
import socket
import optparse
import logging
import json
import inspect

import daemon
コード例 #3
0
ファイル: admin.py プロジェクト: lchaparr/ThesisCode
    def index(self):
        '''Status page.
        '''

        table = '''
            <tr>
                <th>Service</th>
                <th>Jobs</th>
                <th>Status</th>
                <th>Link</th>
                <th>Actions</th>
            </tr>
        '''

        def makeAction(service, action, disabled=False):
            actionTemplate = '''
                <form action="%s" method="get"><input name="service" type="hidden" value="%s" /><input value="%s" type="submit" %s /></form>
            '''

            disabledText = ''
            if disabled:
                disabledText = 'disabled="disabled"'

            return actionTemplate % (action, service, action, disabledText)

        for service in ['keeper'
                        ] + config.getServicesList(showHiddenServices=True):
            jobs = ''
            status = ''
            url = ''

            enabledJobs = keeper.hasEnabledJobs(service)
            if enabledJobs:
                jobs = 'Enabled'

            pids = keeper.getPIDs(service)
            running = len(pids) > 0
            if running:
                status = ','.join(pids)

                url = '/%s/' % service
                if service != 'keeper':
                    url = '<a href="%s">%s</a>' % (url, url)

            # FIXME: Add the ability to restart/stop/kill the admin service via a proxy process
            #        and returning a proper message to the user.
            actions = ''
            for action in ['tail', 'logs', 'joblogs']:
                actions += makeAction(service, action)
            for action in ['lsof', 'env']:
                actions += makeAction(service, action, not running)
            for action in ['start']:
                actions += makeAction(service, action, running
                                      or service == 'admin')
            for action in ['stop', 'restart', 'kill']:
                actions += makeAction(service, action, not running
                                      or service == 'admin')
            for action in ['enableJobs']:
                actions += makeAction(service, action, enabledJobs
                                      or service == 'keeper')
            for action in ['disableJobs']:
                actions += makeAction(service, action, not enabledJobs
                                      or service == 'keeper')

            table += '''
                <tr>
                    <td>%s</td>
                    <td>%s</td>
                    <td>%s</td>
                    <td>%s</td>
                    <td>%s</td>
                </tr>
            ''' % (service, jobs, status, url, actions)

        return indexTemplate.render(table=table)
コード例 #4
0
ファイル: keeper.py プロジェクト: andresib/ThesisCode
#!/usr/bin/env python2.6
'''Keeper of the CMS DB Web services.
'''

__author__ = 'Miguel Ojeda'
__copyright__ = 'Copyright 2012, CERN CMS'
__credits__ = ['Miguel Ojeda', 'Andreas Pfeiffer']
__license__ = 'Unknown'
__maintainer__ = 'Miguel Ojeda'
__email__ = '*****@*****.**'


import config

services = config.getServicesList(showHiddenServices = True)


import os
import glob
import subprocess
import sys
import signal
import time
import smtplib
import email
import socket
import optparse
import logging
import json
import inspect
コード例 #5
0
def main():
    options = {
        'outputDirectory': defaultOutputDirectory,
    }

    # Generate all the docs
    mdwn = markdown.Markdown(safe_mode='escape', extensions=['headerid'])

    documentsList = ''
    inputFilenameRE = re.compile('^(.*)\.mdwn$')
    titleRE = re.compile('^# (.*)$', re.MULTILINE)
    sectionsRE = re.compile('^<h2 id="(.*)">(.*)</h2>$', re.MULTILINE)

    for inputFilename in sorted(os.listdir('.')):
        match = inputFilenameRE.match(inputFilename)
        if not match:
            continue

        outputName = match.groups()[0]
        outputFilename = os.path.join(options['outputDirectory'],
                                      outputName + '.html')

        logging.info('Generating: ' + outputFilename + ' from ' +
                     inputFilename)

        fd = open(inputFilename, 'r')
        inputText = fd.read()
        fd.close()

        # If there is a line starting with # (i.e. <h1>), use it as the title.
        # Otherwise default to the outputName.
        title = outputName
        match = titleRE.search(inputText)
        if match:
            title = match.groups()[0]

        bodyText = mdwn.convert(inputText)

        # Search for sections (i.e. ##, <h2>) and build the index with them.
        # This is done after convert() because the headerid extension generates IDs for us automatically.
        index = None
        match = sectionsRE.search(bodyText)
        if match:
            index = '<h2>Index</h2><ol>'
            for section in sectionsRE.findall(bodyText):
                index += '<li><a href="#%s">%s</a></li>' % section
            index += '</ol>'

            # Put the index just before the first section
            # (so that the "abstract" or "introduction" is kept
            # after the title but before the index)
            firstSection = bodyText.find('<h2')
            bodyText = bodyText[:firstSection] + index + bodyText[firstSection:]

        outputText = docsTemplate.render(title=title, body=bodyText)

        write(outputFilename, outputText)

        # Add the doc to the global index
        documentsList += '<li><a href="%s">%s</a></li>' % (outputName +
                                                           '.html', title)

    # Generate a simple docs' index (i.e. a list of the files)
    outputFilename = os.path.join(options['outputDirectory'], indexFilename)
    logging.info('Generating: ' + outputFilename)

    developmentMailingList = read('developmentMailingList.txt')
    gitWeb = read('gitWeb.txt')
    jiraWeb = read('jiraWeb.txt')

    servicesList = ''
    for service in config.getServicesList():
        servicesList += '<li><a href="/%s/">%s</a></li>' % (service, service)

    bodyText = '''
        <h1>%s</h1>
        <p>Services:</p><ul>%s</ul>
        <p>Development mailing list (you need to be subscribed):</p><ul><li><a href="mailto:%s">%s</a></li></ul>
        <p>Git web:</p><ul><li><a href="%s">%s</a></li></ul>
        <p>JIRA web:</p><ul><li><a href="%s">%s</a></li></ul>
        <p>Documents:</p><ul>%s</ul>
        <p>If it is your first time, please start by reading Developing.</p>
    ''' % (indexTitle, servicesList, developmentMailingList,
           developmentMailingList, gitWeb, gitWeb, jiraWeb, jiraWeb,
           documentsList)

    outputText = docsTemplate.render(title=indexTitle, body=bodyText)
    write(outputFilename, outputText)
コード例 #6
0
ファイル: admin.py プロジェクト: RREYESAL/RPC_HVScan
    def index(self):
        '''Status page.
        '''

        table = '''
            <tr>
                <th>Service</th>
                <th>Jobs</th>
                <th>Status</th>
                <th>Link</th>
                <th>Actions</th>
            </tr>
        '''

        def makeAction(service, action, disabled = False):
            actionTemplate = '''
                <form action="%s" method="get"><input name="service" type="hidden" value="%s" /><input value="%s" type="submit" %s /></form>
            '''

            disabledText = ''
            if disabled:
                disabledText = 'disabled="disabled"'

            return actionTemplate % (action, service, action, disabledText)

        for service in ['keeper'] + config.getServicesList(showHiddenServices = True):
            jobs = ''
            status = ''
            url = ''

            enabledJobs = keeper.hasEnabledJobs(service)
            if enabledJobs:
                jobs = 'Enabled'

            pids = keeper.getPIDs(service)
            running = len(pids) > 0
            if running:
                status = ','.join(pids)

                url = '/%s/' % service
                if service != 'keeper':
                    url = '<a href="%s">%s</a>' % (url, url)

            # FIXME: Add the ability to restart/stop/kill the admin service via a proxy process
            #        and returning a proper message to the user.
            actions = ''
            for action in ['tail', 'logs', 'joblogs']:
                actions += makeAction(service, action)
            for action in ['lsof', 'env']:
                actions += makeAction(service, action, not running)
            for action in ['start']:
                actions += makeAction(service, action, running or service == 'admin')
            for action in ['stop', 'restart', 'kill']:
                actions += makeAction(service, action, not running or service == 'admin')
            for action in ['enableJobs']:
                actions += makeAction(service, action, enabledJobs or service == 'keeper')
            for action in ['disableJobs']:
                actions += makeAction(service, action, not enabledJobs or service == 'keeper')

            table += '''
                <tr>
                    <td>%s</td>
                    <td>%s</td>
                    <td>%s</td>
                    <td>%s</td>
                    <td>%s</td>
                </tr>
            ''' % (service, jobs, status, url, actions)

        return indexTemplate.render(table = table)