IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31231


Ignore:
Timestamp:
Apr 7, 2011, 10:06:53 AM (15 years ago)
Author:
rhenders
Message:

Fixed publish method so that it knows of success/failure; added removal method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/jython/datastore.py

    r31226 r31231  
    44import tempfile
    55import logging
     6import sys
    67from xml.etree.ElementTree import ElementTree, Element, tostring
    78
     
    2728        self.type = doc.find("datastore/type").text
    2829
    29         self.logger.debug("Publishing to '" + self.product + "' product")
    30 
     30        self.logger.debug("Using product: '" + self.product + "' and type: '" + self.type + "'")
    3131
    3232    '''
     
    3535    def publish(self, name, path, file, fileType):
    3636
     37        self.logger.info("Attempting to publish '" + path +"/" + file + "' to datastore product: '" + self.product + "', type: '" + self.type + "'")
    3738        tempFile = tempfile.NamedTemporaryFile(mode='w+b')
    3839        tempFile.write(file + "|||" + fileType)
     
    4849        p = Popen(command, shell=True, stdout=PIPE)
    4950        p.wait()
    50        
    51         #TODO check success print "Return from dsreg: " + p.stdout.read()
     51
     52        if p.returncode != 0:
     53            self.logger.error("Datastore publish failed")
     54            ret = False
     55        else:
     56            self.logger.info("Datastore publish successful")
     57            ret = True
     58           
    5259
    5360        tempFile.close()
     61        return ret
     62
     63
     64    '''
     65    Removes an item to the datastore
     66    '''
     67    def remove(self, name):
     68
     69        command = "dsreg \
     70                   --del " + name + " \
     71                   --rm \
     72                   --product " + self.product
     73
     74        p = Popen(command, shell=True, stdout=PIPE)
     75        p.wait()
     76
     77        if p.returncode != 0:
     78            self.logger.error("Datastore removal of " + name + " failed")
     79            ret = False
     80        else:
     81            ret = True
     82            self.logger.info("Datastore removal of " + name + " successful")
     83           
     84        return ret
     85
Note: See TracChangeset for help on using the changeset viewer.