def __init__(self,
              config=('.primus/deploy.conf', 'DEFAULT'),
              tables=(),
              dependencies=[]):
     Artifact.__init__(self, ':checkdbschema', dependencies)
     load_mysql_parameters(self, config[0], config[1])
     assert tables and len(tables) > 0
     self.tables = tables
 def __init__(self,
              name=":checkmysql",
              config=('.primus/deploy.conf', 'DBADMIN'),
              required_version=(5, 0)):
     assert config
     Artifact.__init__(self, name)
     self.required_version = required_version
     self.config = config
示例#3
0
    def build(self):
        realpath = os.path.join(Artifact.home_dir(), self.path)

        if not os.path.exists(realpath):
            raise IOError("Path '%s' link has to refer does not exist." % self.path)

        os.chdir(Artifact.home_dir())
        if os.path.exists(self.name):
            os.unlink(self.name)
            
        os.symlink(realpath, self.name)    
    def __init__(self,
                 config=('.primus/deploy.conf', 'DBADMIN', 'DEFAULT'),
                 dependencies=[]):
        Artifact.__init__(self, ':createdb', dependencies)
        load_mysql_parameters(self, config[0], config[2])

        class Credentials(object):
            pass

        self.credentials = Credentials()
        load_mysql_parameters(self.credentials, config[0], config[1])
示例#5
0
 def build(self):    
     self.cleanup_log()
     config_path = self.fullpath()
     source_conf = ConfigParser.ConfigParser({'home_dir':Artifact.home_dir()})     
     source_conf.read([config_path])
                     
     for conf_file in self.generator():
         self.configure(source_conf, conf_file)            
示例#6
0
 def cleanup(self):
     path = self.fullpath()
     if os.path.exists(path):
         if os.path.isdir(path) : 
             os.chdir(Artifact.home_dir())
             shutil.rmtree(self.name)
         else: 
             raise IOError()
示例#7
0
    def build(self):
        self.cleanup_log()
        config_path = self.fullpath()
        source_conf = ConfigParser.ConfigParser(
            {'home_dir': Artifact.home_dir()})
        source_conf.read([config_path])

        for conf_file in self.generator():
            self.configure(source_conf, conf_file)
def load_mysql_parameters(obj, config_path, section='DEFAULT'):
    if not os.path.isabs(config_path):
        config_path = os.path.join(Artifact.home_dir(), config_path)

    if not os.path.exists(config_path):
        raise IOError("Configuration file '%s' cannot be found." % config_path)
    c = ConfigParser.ConfigParser()
    c.read([config_path])
    obj.username = c.get(section, 'user')
    obj.password = c.get(section, 'passwd')
    obj.hostname = c.get(section, 'host')
    obj.dbname = c.get(section, 'db')
示例#9
0
def load_mysql_parameters(obj, config_path, section = 'DEFAULT'):   
    if not os.path.isabs(config_path):
        config_path = os.path.join(Artifact.home_dir(), config_path)
   
    if not os.path.exists(config_path) : 
        raise IOError("Configuration file '%s' cannot be found." % config_path)
    c = ConfigParser.ConfigParser()
    c.read([config_path])
    obj.username = c.get(section, 'user') 
    obj.password = c.get(section, 'passwd')
    obj.hostname = c.get(section, 'host')
    obj.dbname   = c.get(section, 'db')
示例#10
0
    def build(self):
        self.destination.build()
        zippath     = self.fullpath()
        destination = self.destination.fullpath()

        tmp  = tempfile.mkstemp(dir=Artifact.home_dir())
        null = open(tmp[1], "w")
        try: 
            ShellScriptHelper.run('unzip', " %s -d %s " % (zippath, destination), False, null)   
        finally: 
            null.close()
            os.remove(tmp[1])
示例#11
0
 def class_path(self):
     classpath = []
     for path in self.classpath:
         path = os.path.join(Artifact.home_dir(), path)
         
         if not os.path.exists(path):
             raise BaseException("Invalid classpath item '%s'" % path)
         
         if os.path.isdir(path):
             for jar in self.collect_jars(path):
                 classpath.append(jar)
         else: 
             classpath.append(path)
     
     return ":".join(classpath)
示例#12
0
    def build(self):
        super(DownloadArchivedFiles, self).build()

        tmp = tempfile.mkstemp(dir=Artifact.home_dir())
        try:
            RemoteFile(os.path.basename(tmp[1]), self.url).build()
            if self.use_shell_unzip: self.shell_unzip(os.path.basename(tmp[1]))
            else: self.py_unzip(tmp[1])
        finally:
            os.remove(tmp[1])

        if self.do_if_absent != None:
            p = os.path.join(self.fullpath(), self.do_if_absent)
            if not os.path.exists(p):
                raise BaseException("File '%s' cannot be found after unzip" %
                                    p)
示例#13
0
    def build(self):
        super(DownloadArchivedFiles, self).build()

        tmp = tempfile.mkstemp(dir=Artifact.home_dir())
        try:
            RemoteFile(os.path.basename(tmp[1]), self.url).build()
            if self.use_shell_unzip:
                self.shell_unzip(os.path.basename(tmp[1]))
            else:
                self.py_unzip(tmp[1])
        finally:
            os.remove(tmp[1])

        if self.do_if_absent != None:
            p = os.path.join(self.fullpath(), self.do_if_absent)
            if not os.path.exists(p):
                raise BaseException("File '%s' cannot be found after unzip" % p)
示例#14
0
    def build(self):
        path = self.fullpath()
        if os.path.isdir(path):
            path = os.path.join(path, "setup.py")
            if not os.path.exists(path):
                raise BaseException("Setup file '%s' doesn't exist." % path)

        pkg_folder = os.path.dirname(path)
        lib_root = os.path.join(Artifact.home_dir(), self.lib)
        if not os.path.exists(lib_root) or not os.path.isdir(lib_root):
            raise BaseException("Lib folder '%s' doesn't exist." % path)

        os.chdir(pkg_folder)

        cmd = "python %s -q " % os.path.basename(path)
        ShellScriptHelper.run(cmd + " build  --build-lib %s" % lib_root)
        ShellScriptHelper.run(cmd + " install --install-lib %s  --install-headers %s" % (lib_root, lib_root))

        shutil.rmtree(os.path.join(pkg_folder, "build"))
示例#15
0
    def build(self):
        path = self.fullpath()
        if os.path.isdir(path):
            path = os.path.join(path, "setup.py")
            if not os.path.exists(path):
                raise BaseException("Setup file '%s' doesn't exist." % path)

        pkg_folder = os.path.dirname(path)
        lib_root = os.path.join(Artifact.home_dir(), self.lib)
        if not os.path.exists(lib_root) or not os.path.isdir(lib_root):
            raise BaseException("Lib folder '%s' doesn't exist." % path)

        os.chdir(pkg_folder)

        cmd = "python %s -q " % os.path.basename(path)
        ShellScriptHelper.run(cmd + " build  --build-lib %s" % lib_root)
        ShellScriptHelper.run(
            cmd + " install --install-lib %s  --install-headers %s" %
            (lib_root, lib_root))

        shutil.rmtree(os.path.join(pkg_folder, "build"))
示例#16
0
 def generator(self): 
     for conf in self.target:
         conf = os.path.join(Artifact.home_dir(), conf)
         yield conf
示例#17
0
 def __init__(self, required_version=(2, 5), dependencies=[]):
     Artifact.__init__(self, ":checkpython", dependencies)
     self.required_version = required_version
示例#18
0
 def generator(self):
     for conf in self.target:
         conf = os.path.join(Artifact.home_dir(), conf)
         yield conf
示例#19
0
 def __init__(self, name, url, dependencies=[]):
     p = os.path.join(Artifact.home_dir(), name)
     if os.path.isdir(p):
         name = os.path.join(name, url.split("/")[-1])
     RemoteFile.__init__(self, name, url, dependencies)
示例#20
0
 def __init__(self,
              config=('.primus/deploy.conf', 'DEFAULT'),
              dependencies=[]):
     Artifact.__init__(self, ':checkdb', dependencies)
     load_mysql_parameters(self, config[0], config[1])
示例#21
0
 def __init__(self, config=('.primus/deploy.conf', 'DEFAULT'), dependencies=[]):
     Artifact.__init__(self, ':checkdb',  dependencies)
     load_mysql_parameters(self, config[0], config[1])
示例#22
0
 def __init__(self, config=('.primus/deploy.conf', 'DEFAULT'), tables=(), dependencies=[]):
     Artifact.__init__(self, ':checkdbschema',  dependencies)
     load_mysql_parameters(self, config[0], config[1])
     assert tables and len(tables) > 0
     self.tables = tables
示例#23
0
 def __init__(self, config=('.primus/deploy.conf', 'DBADMIN', 'DEFAULT'), dependencies=[]):
     Artifact.__init__(self, ':createdb', dependencies)
     load_mysql_parameters(self, config[0], config[2])
     class Credentials(object) : pass
     self.credentials = Credentials()
     load_mysql_parameters(self.credentials, config[0], config[1])
示例#24
0
 def __init__ (self, name, dependencies=[]):
     Artifact.__init__(self, name, dependencies)
     if os.path.isabs(self.name):
         raise BaseException("File artifact '%s' cannot have absolute path" % name)         
示例#25
0
    def fullpath(self): return os.path.join(Artifact.home_dir(), self.name)


class AcquiredFile(FileArtifact):
示例#26
0

__all__ = ['artifactcore', 'fileartifact', 'pyartifact', 'repartifact', 'mysqlartifact', 'confartifact', 'javaartifact']
from artifactcore import Artifact
print "\n:: Primus - deployment tool"
print ":: v1.4.1, Apr 2012"
print ":: target project home: '%s'\n" % (Artifact.home_dir()) 
示例#27
0
 def __init__(self, name=":checkmysql", config=('.primus/deploy.conf', 'DBADMIN'), required_version=(5,0)):
     assert config
     Artifact.__init__(self, name)
     self.required_version = required_version
     self.config = config
示例#28
0
__all__ = [
    'artifactcore', 'fileartifact', 'pyartifact', 'repartifact',
    'mysqlartifact', 'confartifact', 'javaartifact'
]
from artifactcore import Artifact
print "\n:: Primus - deployment tool"
print ":: v1.4.1, Apr 2012"
print ":: target project home: '%s'\n" % (Artifact.home_dir())
示例#29
0
 def __init__(self, name, url, dependencies=[]):
     p = os.path.join(Artifact.home_dir(), name)
     if os.path.isdir(p): name = os.path.join(name, url.split('/')[-1])
     RemoteFile.__init__(self, name, url, dependencies)
示例#30
0
 def __init__(self, required_version=(2, 5), dependencies=[]):
     Artifact.__init__(self, ":checkpython", dependencies)
     self.required_version = required_version