Пример #1
0
	def run(self, type='development', files='all', release=today):
		self.checkSetup()
		
		if not os.path.isdir(os.path.join(self.buildDir, release)) and not os.path.isdir(os.path.join(self.buildDir, self.today)):
			Release().create(files)
		else:
			print('Do you want to update your release build [Y/n]?')
			if sys.stdin.readline() != 'n\n':
				Release().create(files)
		
		if type == 'catroidtest':
			for line in fileinput.FileInput(os.path.join(self.buildDir, release, 'config.php'), inplace=1):
				if "define('UPDATE_AUTH_TOKEN" in line:
					line = "define('UPDATE_AUTH_TOKEN',true);\n" 
				sys.stdout.write(line)
		
		if type == 'public':
			for line in fileinput.FileInput(os.path.join(self.buildDir, release, 'config.php'), inplace=1):
				if "define('DEVELOPMENT_MODE" in line:
					line = "define('DEVELOPMENT_MODE',false);\n" 
				sys.stdout.write(line)
		
		print type
		if type == 'development':
		  sqlShell = Sql(self.remoteCommand,'webtest')
		else:
			sqlShell = Sql(self.remoteCommand,'catroweb')
		  
		if sqlShell.checkConnection():
			self.upload(os.path.join(self.buildDir, release), self.remoteDir)
			self.moveFilesIntoPlace(os.path.join(self.buildDir, release), release)
			sqlShell.initDbs()
		else:
			print('ERROR: deployment failed!')
			self.sftp.put(os.path.join(self.basePath, 'passwords.php'), os.path.join(self.remoteDir, 'passwords.php'))
Пример #2
0
	def restoreBackup(self, backup):
		tempResources = 'resources-tmp'
		if 'No such file' not in commands.getoutput('ls ' + os.path.join(os.getcwd(), backup)):
			sqlShell = Sql(self.run)
			if sqlShell.checkConnection():
				self.upload(os.path.join(os.getcwd(), backup), os.path.join(self.remoteDir, backup))

				result = self.run('tar -xf ' + backup)
				if 'Error' in result:
					print result
					sys.exit(-1)
					
				sqlShell.restoreDbs('sql.tar')
				self.run('rm -rf sql.tar')
				
				self.run('mkdir -p resources-tmp')
				result = self.run('tar -xf resources.tar -C resources-tmp')
				if 'Error' in result:
					print result
					sys.exit(-1)
				
				
				self.run('mv resources resources-old; mv resources-tmp/resources resources')
				self.run('rm -rf resources-old resources-tmp resources.tar')
				self.run('mkdir -p resources/catroid; for file in resources/projects/*; do filename=`basename "$file"`; unzip -d "resources/catroid/${filename%.*}" "$file"; done')
				self.run('chmod -R 0777 resources')

				print 'restored backup: ' + backup
		else:
			print 'FATAL ERROR: No such file: ' + backup
Пример #3
0
    def run(self, type='development', files='all', release=today):
        self.checkSetup()

        if not os.path.isdir(os.path.join(
                self.buildDir, release)) and not os.path.isdir(
                    os.path.join(self.buildDir, self.today)):
            Release().create(files)
        else:
            print('Do you want to update your release build [Y/n]?')
            if sys.stdin.readline() != 'n\n':
                Release().create(files)

        if type == 'catroidtest':
            for line in fileinput.FileInput(os.path.join(
                    self.buildDir, release, 'config.php'),
                                            inplace=1):
                if "define('UPDATE_AUTH_TOKEN" in line:
                    line = "define('UPDATE_AUTH_TOKEN',true);\n"
                sys.stdout.write(line)

        if type == 'public':
            for line in fileinput.FileInput(os.path.join(
                    self.buildDir, release, 'config.php'),
                                            inplace=1):
                if "define('DEVELOPMENT_MODE" in line:
                    line = "define('DEVELOPMENT_MODE',false);\n"
                sys.stdout.write(line)

        print type
        if type == 'development':
            sqlShell = Sql(self.remoteCommand, 'webtest')
        else:
            sqlShell = Sql(self.remoteCommand, 'catroweb')

        if sqlShell.checkConnection():
            self.upload(os.path.join(self.buildDir, release), self.remoteDir)
            self.moveFilesIntoPlace(os.path.join(self.buildDir, release),
                                    release)
            sqlShell.initDbs()
        else:
            print('ERROR: deployment failed!')
            self.sftp.put(os.path.join(self.basePath, 'passwords.php'),
                          os.path.join(self.remoteDir, 'passwords.php'))
Пример #4
0
	def createBackup(self):
		sqlShell = Sql(self.run)
		if sqlShell.checkConnection():
			sqlShell.backupDbs()
			self.run('tar -c resources.tar --no-recursion resources/*')
			for project in sqlShell.getProjectList():
				self.run('tar --append --file=resources.tar resources/projects/%s.*' % project)
				self.run('tar --append --file=resources.tar resources/thumbnails/%s_small*' % project)
				self.run('tar --append --file=resources.tar resources/thumbnails/%s_large*' % project)

			for featuredProject in sqlShell.getFeaturedProjectList():
				self.run('tar --append --file=resources.tar resources/featured/%s.*' % featuredProject)
			
			self.run('tar --append --file=resources.tar resources/thumbnails/thumbnail_small.png')
			self.run('tar --append --file=resources.tar resources/thumbnails/thumbnail_large.png')
			
			self.run('tar -zcf catroweb-' + self.today + '.tar.gz sql.tar resources.tar')
			self.run('rm sql.tar resources.tar')
			self.download(os.path.join(self.remoteDir, 'catroweb-' + self.today + '.tar.gz'), os.path.join(os.getcwd(), 'catroweb-' + self.today + '.tar.gz'))
			print 'created backup'
Пример #5
0
	def createBackup(self):
		print 'connecting sql...'
		sqlShell = Sql(self.run)
		if sqlShell.checkConnection():
			print '----start creating sql backup...'
			sqlShell.backupDbs()
			print '----end creating sql backup.'
			print '----start creating resources backup...'
			self.run('rm resources.tar',0)
			self.run('tar -c resources.tar --no-recursion resources/*',0)
			'''for project in sqlShell.getProjectList():
				self.run('tar --append --file=resources.tar resources/projects/%s.*' % project)
				self.run('tar --append --file=resources.tar resources/thumbnails/%s_small*' % project)
				self.run('tar --append --file=resources.tar resources/thumbnails/%s_large*' % project)
			'''
			print 'packing featured'
			self.run('tar --append --file=resources.tar resources/featured/*')
			
			print 'packing projects'
			self.run('tar --append --file=resources.tar resources/projects/*')
			
			print 'packing thumbnails'
			self.run('tar --append --file=resources.tar resources/thumbnails/*')
			
			
			'''for featuredProject in sqlShell.getFeaturedProjectList():
				self.run('tar --append --file=resources.tar resources/featured/%s.*' % featuredProject)
			
			self.run('tar --append --file=resources.tar resources/thumbnails/thumbnail_small.png')
			self.run('tar --append --file=resources.tar resources/thumbnails/thumbnail_large.png')
			'''
			print '----end creating resources backup.'
			print 'adding sql and resources into one package...'
			self.run('tar -zcf catroweb-' + self.today + '.tar.gz sql.tar resources.tar')
			self.run('rm sql.tar resources.tar')
			print 'generated package size:'+ self.run('du -h catroweb-' + self.today + '.tar.gz')
			print 'downloading the package...'
			self.download(os.path.join(self.remoteDir, 'catroweb-' + self.today + '.tar.gz'), os.path.join(os.getcwd(), 'catroweb-' + self.today + '.tar.gz'))
			print 'created backup'
		else:
			print 'failed'