コード例 #1
0
ファイル: skdb-get.py プロジェクト: pib/skdb
def get_package(package_name, verbose=False, repo=settings.paths["repositories"], package_dir=skdb.settings.paths["package_dir"], branch="master", *args, **keywords):
    '''usage: %prog <package name> [--verbose] [--repo <URL>] [--package-dir /usr/local/share/skdb/] [--branch master]
    download hardware and exit'''
    #assert not have_package(package_name), "package already installed"
    if package_name == "help" or package_name == "": print get_package.__doc__ #how do i do this?

    if not isinstance(repo, list): repo = [repo] #it's actually a list in the config file
    if repo[0][-1:] != "/": repo[0] = repo[0]+"/" #add trailing slash to url if not there
    package_url = repo[0] + package_name + "/.git"

    #make package_dir exist
    os.system('mkdir -p "%s"' % (package_dir)) #package names cant have spaces so why the quotes?
    
    subdir = os.path.join(package_dir, package_name)
    if os.path.exists(subdir):
        command = 'cd "%s"; git pull origin "%s"' % (subdir, branch)
        print "updating:", package_name
    else: 
        command = 'cd "%s"; git clone "%s"' % (package_dir, package_url)
        print "installing:", package_name
    if verbose: print "command is: ", command
    exit_status = os.system(command)
    if exit_status != 0: raise EnvironmentError, "something went wrong at "+ package_url
    if verbose: print "checking %s for dependencies..." % (package_name)
        
    return

if __name__ == '__main__':
    optfunc.run(get_package)
コード例 #2
0
ファイル: skdb-get.py プロジェクト: rituparnamatkar/skdb
    if not isinstance(repo, list):
        repo = [repo]  #it's actually a list in the config file
    if repo[0][-1:] != "/":
        repo[0] = repo[0] + "/"  #add trailing slash to url if not there
    package_url = "git://" + repo[0] + "/" + package_name + ".git"

    #make package_dir exist
    os.system(
        'mkdir -p "%s"' %
        (package_dir))  #package names cant have spaces so why the quotes?

    subdir = os.path.join(package_dir, package_name)
    if os.path.exists(subdir):
        command = 'cd "%s"; git pull origin "%s"' % (subdir, branch)
        print "updating:", package_name
    else:
        command = 'cd "%s"; git clone "%s"' % (package_dir, package_url)
        print "installing:", package_name
    if verbose: print "command is: ", command
    exit_status = os.system(command)
    if exit_status != 0:
        raise EnvironmentError, "something went wrong at " + package_url
    if verbose: print "checking %s for dependencies..." % (package_name)

    return


if __name__ == '__main__':
    optfunc.run(get_package)
コード例 #3
0
ファイル: pov2png.py プロジェクト: KinaMarie/skdb
#!/usr/bin/python
#pov2png.py input.pov output.png
#TODO: automatically figure out the proper dimensions of the resulting image
import skdb.thirdparty.optfunc as optfunc
import os

def pov2png(pov_file, png_file):
    '''usage: %prog <pov_file> <png_file>
    converts from pov to a png file'''
    print "pov2png: starting"
    print "pov_file is: ", pov_file
    print "png_file is: ", png_file
    os.system("povray -d %s +O%s" % (pov_file, png_file))
    print "pov2png: done"

if __name__ == "__main__":
    optfunc.run(pov2png)
コード例 #4
0
ファイル: stl2pov.py プロジェクト: KinaMarie/skdb
    os.system("stl2pov -s %s > %s.inc" % (stl_file, pov_file))
    pov_template = '''#include "%s.inc"

    background{color rgb 1 }    

    object{  m_facet 
    rotate 90*x

    texture{  pigment{ color rgb <1,0.5,0> }
             finish {   ambient 0.15
                        diffuse 0.85
                        specular 0.3 } } } 

    light_source {  <-20,100,20>  color rgb 2}  

    camera {
    perspective
      angle 0
      right x*image_width/image_height
      location <-100,50,10>
      look_at y
    }''' % (pov_file)

    pov_file = open(pov_file, "w")
    pov_file.write(pov_template)
    pov_file.close()

if __name__ == "__main__":
    optfunc.run(stl2pov)

コード例 #5
0
ファイル: iges2png.py プロジェクト: KinaMarie/skdb
    texture{  pigment{ color rgb <1,0.5,0> }
             finish {   ambient 0.15
                        diffuse 0.85
                        specular 0.3 } } } 

    light_source {  <-20,100,20>  color rgb 2}  

    camera {
    perspective
      angle 0
      right x*image_width/image_height
      location <-100,50,10>
      look_at y
    }''' % (pov_file)

    pov_file = open(pov_file, "w")
    pov_file.write(pov_template)
    pov_file.close()

def pov2png(pov_file, png_file):
    '''usage: %prog <pov_file> <png_file>
    converts from pov to a png file'''
    print "pov2png: starting"
    print "pov_file is: ", pov_file
    print "png_file is: ", png_file
    os.system("povray -d %s +O%s" % (pov_file, png_file))
    print "pov2png: done"

if __name__ == "__main__":
    optfunc.run(iges2png)
コード例 #6
0
ファイル: pov2png.py プロジェクト: rituparnamatkar/skdb
#!/usr/bin/python
#pov2png.py input.pov output.png
#TODO: automatically figure out the proper dimensions of the resulting image
import skdb.thirdparty.optfunc as optfunc
import os


def pov2png(pov_file, png_file):
    '''usage: %prog <pov_file> <png_file>
    converts from pov to a png file'''
    print "pov2png: starting"
    print "pov_file is: ", pov_file
    print "png_file is: ", png_file
    os.system("povray -d %s +O%s" % (pov_file, png_file))
    print "pov2png: done"


if __name__ == "__main__":
    optfunc.run(pov2png)
コード例 #7
0
                        diffuse 0.85
                        specular 0.3 } } } 

    light_source {  <-20,100,20>  color rgb 2}  

    camera {
    perspective
      angle 0
      right x*image_width/image_height
      location <-100,50,10>
      look_at y
    }''' % (pov_file)

    pov_file = open(pov_file, "w")
    pov_file.write(pov_template)
    pov_file.close()


def pov2png(pov_file, png_file):
    '''usage: %prog <pov_file> <png_file>
    converts from pov to a png file'''
    print "pov2png: starting"
    print "pov_file is: ", pov_file
    print "png_file is: ", png_file
    os.system("povray -d %s +O%s" % (pov_file, png_file))
    print "pov2png: done"


if __name__ == "__main__":
    optfunc.run(iges2png)