rabin 2 years ago
parent
commit
71c2f962f1
5 changed files with 47 additions and 47 deletions
  1. 21 21
      src/tool/cluster.py
  2. 2 2
      src/tool/composer.py
  3. 2 2
      src/tool/dever.py
  4. 19 19
      src/tool/docker.py
  5. 3 3
      src/tool/php.py

+ 21 - 21
src/tool/cluster.py

@@ -44,25 +44,25 @@ class Cluster_Action(Docker_Action):
 	@staticmethod
 	def leave():
 		result = Swarm.leave()
-		print result
+		print(result)
 
 	@staticmethod
 	def drop():
 		Swarm.drop()
-		print 'drop cluster:yes'
+		print('drop cluster:yes')
 
 	@staticmethod
 	def name():
 		arg = Args.name
 		name = Swarm.name(arg)
 		name = name.split("\n")
-		print name[0]
+		print(name[0])
 
 	@staticmethod
 	def names():
 		arg = Args.name
 		name = Swarm.name(arg)
-		print name
+		print(name)
 
 	@staticmethod
 	def node():
@@ -72,12 +72,12 @@ class Cluster_Action(Docker_Action):
 	def num():
 		name = Args.name
 		num = Args.param
-		print 'setting ' + name + ', please wait...'
+		print('setting ' + name + ', please wait...')
 		Swarm.scale(name, num)
 
 	@staticmethod
 	def restart(**param):
-		print 'reloading ' + param['name'] + ', please wait...'
+		print('reloading ' + param['name'] + ', please wait...')
 		name = Swarm.name(param['name'])
 		name = name.split("\n")
 		for i in name:
@@ -105,7 +105,7 @@ class Cluster_Action(Docker_Action):
 
 	@staticmethod
 	def stop(**param):
-		print 'stop command is not exists'
+		print('stop command is not exists')
 
 	@staticmethod
 	def save(**param):
@@ -134,7 +134,7 @@ class Cluster_Action(Docker_Action):
 			Alias.delete(param['config'], param['name'])
 		else:
 			Container.delete()
-			print 'rm cluster:yes'
+			print('rm cluster:yes')
 
 	@staticmethod
 	def rmb(**param):
@@ -143,7 +143,7 @@ class Cluster_Action(Docker_Action):
 			Alias.delete(param['config'], param['name'])
 		else:
 			Swarm.delete()
-			print 'rm cluster:yes'
+			print('rm cluster:yes')
 
 	@classmethod
 	def reset(self, **param):
@@ -153,7 +153,7 @@ class Cluster_Action(Docker_Action):
 	@classmethod
 	def test(self, **param):
 		param['test'] = True
-		print self.run(**param)
+		print(self.run(**param))
 
 	@classmethod
 	def create(self, **param):
@@ -195,13 +195,13 @@ class Cluster_Action(Docker_Action):
 			command = ' '.join(run)
 			if 'test' in param:
 				return 'docker service create ' + command
-			print 'setuping ' + param['name'] + ', please wait...'
+			print('setuping ' + param['name'] + ', please wait...')
 			method = Core.getMethod(Swarm, param['action'])
 			method(command)
 			Alias.add(param['config'], param['name'], 'docker run ' + command, param['action'], True)
 			Cluster.hook('end', param['config'], param['name'])
 		else:
-			print param['name'] + ' cluster is setuped'
+			print(param['name'] + ' cluster is setuped')
 
 	@staticmethod
 	def setting():
@@ -229,7 +229,7 @@ class Cluster_Action(Docker_Action):
 		url = 'http://' + ip + ':8500/v1/kv/' + key
 		Core.popen('curl -X PUT -d "'+value+'" ' + url, bg=True)
 		if p == True:
-			print True
+			print(True)
 		return True
 
 	@classmethod
@@ -243,19 +243,19 @@ class Cluster_Action(Docker_Action):
 		url = 'http://' + ip + ':8500/v1/kv/' + key
 		value = Core.curl(url)
 		if not value:
-			print False
+			print(False)
 			return False
 		value = json.loads(value)
 		value = base64.b64decode(value[0]['Value'])
 		if p == True:
-			print value
+			print(value)
 		return value
 
 	@classmethod
 	def init(self, **param):
 		(ip, ckey) = self.setting()
 		token = Swarm.init(ip)
-		print 'init cluster ...'
+		print('init cluster ...')
 		if token and '--token' in token:
 			Core.popen('dm pull consul')
 			Core.popen('ds run daemon-master')
@@ -268,14 +268,14 @@ class Cluster_Action(Docker_Action):
 
 			self.put(ckey, token, p = False)
 			#Core.popen('consul kv put ' + ckey + ' ' + token)
-		print 'init cluster success! please remember the ip address:'+ip+''
+		print('init cluster success! please remember the ip address:'+ip+'')
 
 	@classmethod
 	def join(self, **param):
 		(ip, ckey) = self.setting()
 		value = self.get(ckey, ip, False)
 		#config = value.split(':')
-		print value
+		print(value)
 
 		'''
 		Core.popen('dm pull consul')
@@ -305,7 +305,7 @@ class Swarm(object):
 		return command
 	@staticmethod
 	def show(name=''):
-		print Core.shell('swarm.show ' + name)
+		print(Core.shell('swarm.show ' + name))
 	@staticmethod
 	def args():
 		return {
@@ -325,7 +325,7 @@ class Swarm(object):
 		Core.shell('swarm.drop', bg=True)
 	@staticmethod
 	def node():
-		print Core.shell('swarm.node')
+		print(Core.shell('swarm.node'))
 	@staticmethod
 	def stop(name):
 		Core.shell('swarm.stop ' + name)
@@ -341,7 +341,7 @@ class Swarm(object):
 	@classmethod
 	def delete(self, name='', bg=False):
 		if name != '':
-			print 'rm ' + name + ', please wait...'
+			print('rm ' + name + ', please wait...')
 			if self.check(name) == 1:
 				Core.shell('swarm.rm ' + name, False, bg=bg)
 		else:

+ 2 - 2
src/tool/composer.py

@@ -17,7 +17,7 @@ class Composer_Action(object):
 	@staticmethod
 	def install():
 		Composer.install(Args.name)
-		print 'install '+Args.name+':yes'
+		print('install '+Args.name+':yes')
 
 	@classmethod
 	def update(self):
@@ -31,4 +31,4 @@ class Composer(object):
 	@staticmethod
 	def install(name):
 		Core.shell('composer.install ' + name, True)
-		print 'finished'
+		print('finished')

+ 2 - 2
src/tool/dever.py

@@ -43,7 +43,7 @@ class Dever(object):
 	def create(self, path):
 		name = os.path.basename(path)
 		Dever_Create.boot(path + '/', name)
-		print "create finished!"
+		print("create finished!")
 
 	@staticmethod
 	def cur(up = True):
@@ -257,7 +257,7 @@ class Dever_Action(object):
 	@classmethod
 	def create(self):
 		path = self.pull()
-		print "creating..."
+		print("creating...")
 		for v in Dever.package_list:
 			Dever_Create.index(path + '/', v['name'], v['path'])
 		Dever.create(path)

+ 19 - 19
src/tool/docker.py

@@ -159,7 +159,7 @@ class Docker(object):
 				if index in param:
 					value = param[index][0]
 				if value == '':
-					print 'please set param value:' + index
+					print('please set param value:' + index)
 					sys.exit()
 				else:
 					result = Core.replace('{$'+key+'}', value, result)
@@ -221,7 +221,7 @@ class Docker_Action(object):
 		Image.build(Docker.storeHost, path, Args.name)
 		Container.delete()
 		Image.delete()
-		print 'docker build '+Args.name+':yes'
+		print('docker build '+Args.name+':yes')
 
 	@classmethod
 	def push(self):
@@ -231,7 +231,7 @@ class Docker_Action(object):
 				#print package[Args.name]
 				Image.push(package[Args.name])
 			else:
-				print 'error ' + Args.name
+				print('error ' + Args.name)
 			sys.exit()
 
 		for key in package:
@@ -245,7 +245,7 @@ class Docker_Action(object):
 			if Args.name in package:
 				Image.pull(package[Args.name])
 			else:
-				print 'error ' + Args.name
+				print('error ' + Args.name)
 			sys.exit()
 
 		for key in package:
@@ -282,12 +282,12 @@ class Docker_Action(object):
 						result[key].append(host)
 		if Args.name and Args.name in result:
 			value = Args.name + ' [' + ",".join(result[Args.name ]) + ']'
-			print value
+			print(value)
 		else:
 			i = 1
 			for key in result:
 				value = key + ' [' + ",".join(result[key]) + ']'
-				print str(i) + ':' + value
+				print(str(i) + ':' + value)
 				i = i + 1
 		return result
 
@@ -298,17 +298,17 @@ class Docker_Action(object):
 	@staticmethod
 	def rmi():
 		Image.delete()
-		print 'rm image:yes'
+		print('rm image:yes')
 
 	@staticmethod
 	def drop():
 		Container.drop()
-		print 'drop container:yes'
+		print('drop container:yes')
 
 	@staticmethod
 	def dropi():
 		Image.drop(Args.name)
-		print 'drop image:yes'
+		print('drop image:yes')
 
 	@staticmethod
 	def show(**param):
@@ -323,7 +323,7 @@ class Docker_Action(object):
 
 	@staticmethod
 	def restart(**param):
-		print 'reloading ' + param['name'] + ', please wait...'
+		print('reloading ' + param['name'] + ', please wait...')
 		Container.restart(param['name'])
 
 	@staticmethod
@@ -361,7 +361,7 @@ class Docker_Action(object):
 			Alias.delete(param['config'], param['name'])
 		else:
 			Container.delete()
-			print 'rm container:yes'
+			print('rm container:yes')
 
 	@staticmethod
 	def rmb(**param):
@@ -370,7 +370,7 @@ class Docker_Action(object):
 			Alias.delete(param['config'], param['name'])
 		else:
 			Container.delete()
-			print 'rm container:yes'
+			print('rm container:yes')
 
 	@classmethod
 	def reset(self, **param):
@@ -380,7 +380,7 @@ class Docker_Action(object):
 	@classmethod
 	def test(self, **param):
 		param['test'] = True
-		print self.run(**param)
+		print(self.run(**param))
 
 	@classmethod
 	def create(self, **param):
@@ -437,7 +437,7 @@ class Docker_Action(object):
 			command = ' '.join(run)
 			if 'test' in param:
 				return 'docker run ' + command
-			print 'setuping ' + param['name'] + ', please wait...'
+			print('setuping ' + param['name'] + ', please wait...')
 			method = Core.getMethod(Container, param['action'])
 			method(command)
 			Alias.add(param['config'], param['name'], 'docker run ' + command, param['action'])
@@ -455,7 +455,7 @@ class Container(object):
 		return command
 	@staticmethod
 	def show(name=''):
-		print Core.shell('container.show ' + name)
+		print(Core.shell('container.show ' + name))
 	@staticmethod
 	def args():
 		return {
@@ -492,7 +492,7 @@ class Container(object):
 	@classmethod
 	def delete(self, name='', bg=False):
 		if name != '':
-			print 'rm ' + name + ', please wait...'
+			print('rm ' + name + ', please wait...')
 			if self.check(name) == 1:
 				Core.shell('container.rm ' + name, False, bg=bg)
 		else:
@@ -543,10 +543,10 @@ class Image(object):
 				Core.shell('image.push ' + store + ' ' + value, bg=True)
 	@classmethod
 	def pull(self, stores):
-		print Core.shell('image.pull ' + stores[0], True)
+		print(Core.shell('image.pull ' + stores[0], True))
 	@staticmethod
 	def show():
-		print Core.shell('image.show')
+		print(Core.shell('image.show'))
 	@staticmethod
 	def drop(name=''):
 		Core.shell('image.drop ' + name, bg=True)
@@ -576,4 +576,4 @@ class Image(object):
 		pull = 'docker pull';
 		command = pull + ' ' + library + key
 		Core.popen(command, True)
-		print 'finished'
+		print('finished')

+ 3 - 3
src/tool/php.py

@@ -36,12 +36,12 @@ class Php_Action(object):
 			so = self.package[Args.name][2]
 			config = self.package[Args.name][3]
 		else:
-			print Args.name+' error'
+			print(Args.name+' error')
 			return
 
 		Core.popen('phpInstall ' + name + ' ' + rely + ' ' + so + ' ' + config, True)
-		print 'install '+Args.name+':yes'
+		print('install '+Args.name+':yes')
 		
 	@classmethod
 	def show(self):
-		print self.package.keys()
+		print(self.package.keys())