<commit_before>#!/usr/bin/python2.4
#
# Copyright (c) 2006-2007 rPath, Inc.  All rights reserved.
#
"""
rMake Backend server
"""
import errno
import itertools
import logging
import pwd
import os
import random
import shutil
import signal
import sys
import time
import traceback
import urllib
import xmlrpclib

from conary.deps import deps
from conary.lib import util

from rmake import errors
from rmake import failure
from rmake import plugins
from rmake.build import builder
from rmake.build import buildcfg
from rmake.build import buildjob
from rmake.build import subscriber
from rmake.server import auth
from rmake.server import publish
from rmake.db import database
from rmake.lib.apiutils import api, api_parameters, api_return, freeze, thaw
from rmake.lib.apiutils import api_nonforking
from rmake.lib import apirpc
from rmake.lib import logger
from rmake.worker import worker

class ServerLogger(logger.ServerLogger):
    name = 'rmake-server'

class rMakeServer(apirpc.XMLApiServer):
    """
        rMake server.

        See rMake client for documentation of API.
    """

    _CLASS_API_VERSION = 1

    @api(version=1)
    @api_parameters(1, 'BuildJob')
    @api_return(1, 'int')
    def buildTroves(self, callData, job):
        callData.logger.logRPCDetails('buildTroves')
        for buildCfg in job.iterConfigList():
            self.updateBuildConfig(buildCfg)
        job.uuid = job.getMainConfig().uuid
        self.db.addJob(job)
        self._subscribeToJob(job)
        self.db.queueJob(job)
        job.jobQueued()
        return job.jobId

    @api(version=1)
    @api_parameters(1, None)
    def stopJob(self, callData, jobId):
        jobId = self.db.convertToJobId(jobId)
        job = self.db.getJob(jobId, withTroves=True)
        self._stopJob(job)
        self._subscribeToJob(job)
        job.jobStopped('User requested stop')

    @api(version=1)
    @api_parameters(1, None, None)
    @api_return(1, None)
    def listJobs(self, callData, activeOnly, jobLimit):
        return self.db.listJobs(activeOnly=activeOnly, jobLimit=jobLimit)

    @api(version=1)
    @api_parameters(1, None, None)
    @api_return(1, None)
    def listTrovesByState(self, callData, jobId, state):
        jobId = self.db.convertToJobId(jobId)
        if state == '':
            state = None
        data = self.db.listTrovesByState(jobId, state)
        return [(x[0], freeze('troveContextTupleList', x[1])) for x in data.iteritems()]<commit_msg>Log the jobId that we're stopping<commit_after>#!/usr/bin/python2.4
#
# Copyright (c) 2006-2007 rPath, Inc.  All rights reserved.
#
"""
rMake Backend server
"""
import errno
import itertools
import logging
import pwd
import os
import random
import shutil
import signal
import sys
import time
import traceback
import urllib
import xmlrpclib

from conary.deps import deps
from conary.lib import util

from rmake import errors
from rmake import failure
from rmake import plugins
from rmake.build import builder
from rmake.build import buildcfg
from rmake.build import buildjob
from rmake.build import subscriber
from rmake.server import auth
from rmake.server import publish
from rmake.db import database
from rmake.lib.apiutils import api, api_parameters, api_return, freeze, thaw
from rmake.lib.apiutils import api_nonforking
from rmake.lib import apirpc
from rmake.lib import logger
from rmake.worker import worker

class ServerLogger(logger.ServerLogger):
    name = 'rmake-server'

class rMakeServer(apirpc.XMLApiServer):
    """
        rMake server.

        See rMake client for documentation of API.
    """

    _CLASS_API_VERSION = 1

    @api(version=1)
    @api_parameters(1, 'BuildJob')
    @api_return(1, 'int')
    def buildTroves(self, callData, job):
        callData.logger.logRPCDetails('buildTroves')
        for buildCfg in job.iterConfigList():
            self.updateBuildConfig(buildCfg)
        job.uuid = job.getMainConfig().uuid
        self.db.addJob(job)
        self._subscribeToJob(job)
        self.db.queueJob(job)
        job.jobQueued()
        return job.jobId

    @api(version=1)
    @api_parameters(1, None)
    def stopJob(self, callData, jobId):
        callData.logger.logRPCDetails('stopJob', jobId=jobId)
        jobId = self.db.convertToJobId(jobId)
        job = self.db.getJob(jobId, withTroves=True)
        self._stopJob(job)
        self._subscribeToJob(job)
        job.jobStopped('User requested stop')

    @api(version=1)
    @api_parameters(1, None, None)
    @api_return(1, None)
    def listJobs(self, callData, activeOnly, jobLimit):
        return self.db.listJobs(activeOnly=activeOnly, jobLimit=jobLimit)

    @api(version=1)
    @api_parameters(1, None, None)
    @api_return(1, None)
    def listTrovesByState(self, callData, jobId, state):
        jobId = self.db.convertToJobId(jobId)
        if state == '':
            state = None
        data = self.db.listTrovesByState(jobId, state)
        return [(x[0], freeze('troveContextTupleList', x[1])) for x in data.iteritems()]
{'fraction_non_alphanumeric': 0.09583833533413365, 'fraction_numerical': 0.009603841536614645, 'mean_word_length': 3.4554367201426026, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '318138', 'n_tokens_mistral': 1637, 'n_tokens_neox': 1604, 'n_words': 424}