def offline(self):
     """Changes the local render node's status to offline"""
     with transaction():
         [thisNode] = Hydra_rendernode.fetch ("where host = '%s'" % Utils.myHostName( ))
         thisNode.status = OFFLINE
         thisNode.update()
     self.updateRenderNodeInfo()
 def online(self):
     """Changes the local render node's status to online if it wasn't on-line already"""
     with transaction():
         [thisNode] = Hydra_rendernode.fetch ("where host = '%s'" % Utils.myHostName( ))
         if thisNode.status == OFFLINE:
             thisNode.status = IDLE
             thisNode.update()
         else:
             logger.debug("Node is already online.")
         self.updateRenderNodeInfo()
 def updateRenderNodeInfo(self):
     with transaction():
         [thisNode] = Hydra_rendernode.fetch ("where host = '%s'" % Utils.myHostName( ))
     
     if thisNode.host:
         self.nameLabel.setText("Node name: " + thisNode.host)
         self.statusLabel.setText("Status: " + codes[thisNode.status])
         if thisNode.task_id:
             self.jobLabel.setText("Job id: {0:d}".format(thisNode.task_id))
         else:
             self.jobLabel.setText("Job id: None")
     else:
         QMessageBox.about(self, "Error", "This computer is not registered as a render node.")
def unregister(host=None):
    """
    Removes the specified node from Hydra_rendernode table. If none provided,
    then it gets the host name of the current machine / configuration and
    removes that from the database. For example, if the current machine's
    computer name is FOO and the DNS extension listed in hydraSettings.cfg is
    .xyz, then the host to be deleted is FOO.xyz
    """
    
    if not host:
        host = Utils.myHostName()
    
    [node] = Hydra_rendernode.fetch("where host = '%s'" % host)
    if node:
        with transaction() as t:
            t.cur.execute("delete from Hydra_rendernode where host = '%s'" % host)
        return True
    
    return False
def unstick (taskID=None, newTaskStatus=READY,
             host=None, newHostStatus=IDLE):
    with transaction () as t:
        if taskID:
            [task] = Hydra_rendertask.fetch ("where id = %d" % taskID)

            # if the task is marked, say, CRASHED, leave the host name alone.
            # only READY would be confusing with a host named filled in. I think.
            if newTaskStatus == READY:
                task.host = None

            task.status = newTaskStatus
            task.startTime = None
            task.endTime = None
            task.update (t)
        if host:
            [host] = Hydra_rendernode.fetch ("where host = '%s'" % host)
            host.task_id = None
            host.status = newHostStatus
            host.update (t)
    def populateProjectComboBox(self):
        """Populates the projects dropdown box."""

        # get current list of projects from the database
        tuples = None
        with transaction() as t:
            t.cur.execute("select * from Hydra_projects")
            tuples = t.cur.fetchall()
        
        # flatten list of tuples fetched from the database
        projectsList = [t for (t,) in tuples]
        
        # populate the dropdown
        for project in projectsList:
            self.projectComboBox.addItem(project)
        
        # show default project selection
        [thisNode] = Hydra_rendernode.fetch(
            "where host = '%s'" % Utils.myHostName())
        idx = self.projectComboBox.findText(
            thisNode.project,
            flags=Qt.MatchExactly|Qt.MatchCaseSensitive)
        self.projectComboBox.setCurrentIndex(idx)
import os

import LoggingSetup
import Utils

from MySQLSetup import Hydra_rendernode, OFFLINE, IDLE, transaction

with transaction () as t:
    [thisNode] = Hydra_rendernode.fetch( "where host = '%s'" % Utils.myHostName( ) )
    if thisNode.status == OFFLINE:
        thisNode.status = IDLE
        thisNode.update(t)
    
import os

import LoggingSetup
import Utils

from MySQLSetup import Hydra_rendernode, OFFLINE, transaction

import ConfigParser

config = ConfigParser.RawConfigParser ()
config.read ("C:/Hydra/hydraSettings.cfg")

me = Utils.myHostName( )
minJobPriority = config.get(section="rendernode", option="minJobPriority")

if Hydra_rendernode.fetch( "where host = '%s'" % me ):
    raise Exception( 'already registered' )

with transaction() as t:
    Hydra_rendernode ( host = me, status = OFFLINE, minPriority = minJobPriority).insert(t)