コード例 #1
0
ファイル: gce_api.py プロジェクト: NIVANorge/watexr
 def generateSSHKey(self):
     display('Generating ssh key...')
     c = Connection('localhost')
     c.local('rm -f "{keyFile}.*"'.format(**self.properties))
     c.local("echo 'yes' | ssh-keygen -t rsa -f {keyFile} -C {username}  -N '' ".format(**self.properties),hide='out')
     c.close()
     #p = Popen("echo 'yes' | ssh-keygen -t rsa -f {keyFile} -C {username} -N '' ".format(**self.properties),
     #              stdout=PIPE,
     #              shell=True,
     #              stderr=PIPE
     #               )
     #print(p.communicate())
     with open (self.properties['pubKeyFile'],'r') as f:
         display('Opening {}'.format(self.properties['pubKeyFile']))
         self.pub = f.read().strip()
コード例 #2
0
ファイル: views.py プロジェクト: cpkthompson/chuck
def prep_files(request):
    container_name = request.GET.get('container_name')
    host = config('MACHINE', default='MACHINE')
    pasw = config('PASW', default='PASW')
    root_image_name = config('ROOT_IMAGE_NAME', default='ROOT_IMAGE_NAME')
    connect = Connection(host=host)
    root_container_id = \
    connect.local('echo {} | sudo -S docker ps | grep {}'.format(pasw, root_image_name)).stdout.rstrip()[0]
    connect.local(
        'echo {} | sudo -S docker cp {}:/data/workspaces/{}/ ./{}'.format(
            pasw, root_container_id, container_name, container_name))
    ignore_dirs = [
        '.che', 'node_modules', '.pyc', 'venv', '.git', '.idea', '.gitignore'
    ]
    ignore_dir_string = ''
    for dir in ignore_dirs:
        ignore_dir_string = ignore_dir_string + " --exclude={}/{}".format(
            container_name, dir)
    connect.local("tar {} -czf {}.tar.gz {}/ -C .".format(
        ignore_dir_string, container_name, container_name))
    return HttpResponse('done')