rabin 8 سال پیش
والد
کامیت
db9108358f
5فایلهای تغییر یافته به همراه439 افزوده شده و 396 حذف شده
  1. 361 0
      src/core.py
  2. 23 341
      src/dever.py
  3. 43 43
      src/docker.py
  4. 8 8
      src/main.py
  5. 4 4
      src/php.py

+ 361 - 0
src/core.py

@@ -0,0 +1,361 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+    dever-manage tools
+    name:Core.py
+    author:rabin
+"""
+import time
+import datetime
+import os
+import sys
+import getopt
+import ConfigParser
+import commands
+import re
+import subprocess
+import urlparse
+
+class Args(object):
+	@classmethod
+	def init(self):
+		self.action = ''
+		self.name = ''
+		self.index = ''
+		self.param = ''
+		self.argv()
+
+	@classmethod
+	def argv(self):
+		slen = len(sys.argv)
+		if slen >= 2:
+			self.action = sys.argv[1]
+		if slen >= 3:
+			self.name = sys.argv[2]
+		if slen >= 4:
+			self.param = sys.argv[3]
+		self.options()
+		if self.action == '':
+			print 'action error'
+			sys.exit()
+		
+	@classmethod
+	def options(self):
+		try:
+			options, args = getopt.getopt(sys.argv[1:], "ha:n:p:", ['help', "action=", "name=", "param="])
+			for name, value in options:
+				if name in ('-h', '--help'):
+					self.usage()
+				elif name in ('-a', '--action'):
+					self.method = value
+				elif name in ('-n', '--name'):
+					Args.name = value
+				elif name in ('-p', '--param'):
+					self.param = value
+		except getopt.GetoptError:
+			self.usage()
+	@classmethod
+	def usage(self):
+		print File.read(Core.path, 'usage')
+		sys.exit()
+
+class Env(object):
+	dm_use = 'base.use'
+	dm_store = 'base.store'
+	dm_val = 'val.'
+	data = {}
+
+	@staticmethod
+	def key(name):
+		return name.split('.')
+
+	@classmethod
+	def init(self, name):
+		if not self.data:
+			self.data = Config.runtime()
+		return self.key(name)
+
+	@classmethod
+	def read(self, name):
+		key, name = self.init(name)
+		if key in self.data and name in self.data[key]:
+			return self.data[key][name]
+		else:
+			return False
+
+	@classmethod
+	def write(self, name, value):
+		key, name = self.init(name)
+		self.data[key][name] = value
+		Config.runtime(key, name, value)
+		return value
+
+	@classmethod
+	def use(self, value=None):
+		if value:
+			return self.write(self.dm_use, value)
+		return self.read(self.dm_use)
+
+	@classmethod
+	def store(self, value=None):
+		if value:
+			return self.write(self.dm_store, value)
+		return self.read(self.dm_store)
+
+	@classmethod
+	def val(self, name='', value=None):
+		name = self.dm_val + name.capitalize()
+		if value:
+			return self.write(name, value)
+		return self.read(name)
+
+class Config(object):
+	@classmethod
+	def runtime(self, key='', name='', value=''):
+		runtime = Core.path + 'data/runtime.conf'
+		if File.exists(runtime):
+			config = ConfigParser.ConfigParser()
+			config.read(runtime)
+			if key and name:
+				config.set(key, name, value)
+				config.write(open(runtime, 'w'))
+			else:
+				result = {}
+				for item in config.sections():
+					result[item] = self.readOption(config, item)
+				return result
+		else:
+			print runtime + ' is not exists'
+			sys.exit()
+
+	@classmethod
+	def core(self, path):
+		core = Core.path + path + 'core.conf'
+		if File.exists(core):
+			config = ConfigParser.ConfigParser()
+			config.read(core)
+			result = {}
+			for item in config.sections():
+				result[item] = self.readOption(config, item)
+			return result
+		else:
+			print core + ' is not exists'
+			sys.exit()
+
+	@classmethod
+	def read(self, path):
+		if '-' in Args.name:
+			temp = Args.name.split('-')
+			Args.name = temp[0]
+			Args.index = temp[1]
+
+		filename = Core.path + path + 'conf/' + Args.name + '.conf'
+		if File.exists(filename):
+			config = ConfigParser.ConfigParser()
+			config.read(filename)
+			result = {}
+			result['server'] = []
+			result['config'] = {}
+			result['base'] = {}
+			for item in config.sections():
+				if item == 'base':
+					result['base'] = self.readOption(config, item)
+				else:
+					result['server'].append(item)
+					result['config'][item] = self.readOption(config, item)
+
+			result['base']['path'] = Core.replace('{base}', Core.path, result['base']['path'])
+			return result
+		else:
+			print filename + ' is not exists'
+			sys.exit()
+
+	@staticmethod
+	def readOption(config, type):
+		value = config.options(type)
+		result = {}
+		for item in value:
+			result[item] = config.get(type, item)
+		return result
+
+class Alias(object):
+	@classmethod
+	def delete(self, config, name):
+		return
+		result = self.get(config, name)
+		for key in result:
+			action = self.action(name, key)
+			Core.popen('rm -rf ' + action[1], bg=True)
+			Core.popen('rm -rf ' + action[2], bg=True)
+	@classmethod
+	def add(self, config, name, content, type):
+		result = self.get(config, name)
+		for key in result:
+			action = self.action(name, key)
+			content = '#!/usr/bin/env sh \nset -e\n'
+			if type != 'call':
+				if action[0] == 'sh':
+					content = content + self.define(name) + \
+						'else\n' + \
+						'docker exec -it ' + name + ' ' + action[0] + ' $@\n' + \
+						'fi'
+				else:
+					content = content + 'docker exec -it ' + name + ' ' + action[0] + ' $@'
+			else:
+				content = content + ' $@'
+			File.write(action[1], content)
+			Core.popen('ln -sf ' + action[1] + ' ' + action[2])
+
+	@staticmethod
+	def define(name):
+		conf = ['logs', 'inspect', 'restart', 'stop', 'rm', 'rmb', 'run', 'uprun', 'show']
+		result = ''
+		for key in conf:
+			control = 'elif'
+			shell = 'dm ' + key + ' ' + name + '\n'
+			if key == 'logs':
+				control = 'if'
+			result = result + control + ' [ "$1" = "'+key+'" ];then\n' + shell
+		return result
+	@classmethod
+	def get(self, config, name):
+		self.path = Core.path + 'data/alias/'
+		result = []
+		default = 'sh->' + name
+		if 'alias' in config:
+			config['alias'] = config['alias'] + ',' + default
+			if ',' in config['alias']:
+				result = config['alias'].split(',');
+			else:
+				result = [config['alias']]
+		else:
+			result = [default]
+		return result
+	@classmethod
+	def action(self, name, key):
+		file = key
+		if '->' in key:
+			temp = key.split('->')
+			key = temp[0]
+			file = temp[1]
+		link = '/usr/bin/' + file
+		file = self.path + file
+		return [key, file, link]
+
+class File(object):
+	@staticmethod
+	def write(file, content):
+		handle = open(file, 'w')
+		handle.write(content)
+		handle.close()
+		Core.popen('chmod +x ' + file)
+
+	@staticmethod
+	def read(path, name):
+		handle = open(path + name, 'r')
+		content = handle.read()
+		handle.close()
+		return content
+
+	@staticmethod
+	def path():
+		return os.path.split(os.path.realpath(__file__))[0] + '/'
+
+	@staticmethod
+	def exists(name):
+		return os.path.exists(name)
+
+	@staticmethod
+	def rename(old, new):
+		return os.rename(old, new)
+
+	@staticmethod
+	def remove(file):
+		return os.remove(file)
+
+	@staticmethod
+	def mkdir(path):
+		if File.exists(path) == False:
+			os.mkdir(path)
+		return path
+
+	@staticmethod
+	def mkdirs(path):
+		if File.exists(path) == False:
+			os.makedirs(path)
+		return path
+
+class Core(object):
+	path = ''
+	@classmethod
+	def getClass(self, name, path=''):
+		obj = self.getObject(name, path)
+		name = name.capitalize()
+		if not hasattr(obj, name):
+			print 'error ' + name
+			sys.exit()
+		return getattr(obj, name)
+
+	@staticmethod
+	def getObject(name, path = ''):
+		return __import__(path + name)
+
+	@staticmethod
+	def getMethod(obj, name):
+		if not hasattr(obj, name):
+			print 'error ' + name
+			sys.exit()
+		return getattr(obj, name)
+
+	@classmethod
+	def shell(self, command, sub=False, bg=False):
+		shell = self.path + 'src/shell/' + command.replace('.', '/', 1)
+		return self.popen(shell, sub, bg)
+	@staticmethod
+	def popen(command, sub=False, bg=False):
+		string = command
+		if bg == True:
+			command = command + ' 1>/dev/null 2>&1 &'
+		if sub == False:
+			process = os.popen(command)
+			output = process.read()
+			process.close()
+			return output
+		else:
+			popen  = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
+			output = ''
+			print string
+			while True:
+				output = popen.stdout.readline()
+				print output
+				if popen.poll() is not None:
+					break
+			return output
+	@classmethod
+	def install(self, soft):
+		print 'install ' + soft + '...'
+		if soft == 'docker':
+			self.shell('install.docker', True)
+		else:
+			self.shell('install.package ' + soft, True)
+	@classmethod
+	def check(self, soft):
+		result = int(Core.popen('which '+soft+' | wc -l'))
+		if result != 0:
+			return 1
+		else:
+			self.install(soft)
+			return 0
+	@staticmethod
+	def replace(old, new, string):
+		if old in string:
+			string = string.replace(old, new)
+		return string
+	@staticmethod
+	def isset(v): 
+		try : 
+			type(eval(v))
+		except : 
+			return  0 
+		else : 
+			return  1

+ 23 - 341
src/dever.py

@@ -2,360 +2,42 @@
 # -*- coding: utf-8 -*-
 """
     dever-manage tools
-    name:dever.py
+    name:php.py
     author:rabin
 """
-import time
-import datetime
-import os
-import sys
-import getopt
-import ConfigParser
-import commands
-import re
-import subprocess
-import urlparse
+from core import *
 
-class Args(object):
+class Dever(object):
+	git = 'http://git.dever.cc:3000/'
+	path = Core.path + 'container/share/lib/php/'
 	@classmethod
 	def init(self):
-		self.action = ''
-		self.name = ''
-		self.index = ''
-		self.param = ''
-		self.argv()
-
-	@classmethod
-	def argv(self):
-		slen = len(sys.argv)
-		if slen >= 2:
-			self.action = sys.argv[1]
-		if slen >= 3:
-			self.name = sys.argv[2]
-		if slen >= 4:
-			self.param = sys.argv[3]
-		self.options()
-		if self.action == '':
-			print 'action error'
-			sys.exit()
-		
-	@classmethod
-	def options(self):
-		try:
-			options, args = getopt.getopt(sys.argv[1:], "ha:n:p:", ['help', "action=", "name=", "param="])
-			for name, value in options:
-				if name in ('-h', '--help'):
-					self.usage()
-				elif name in ('-a', '--action'):
-					self.method = value
-				elif name in ('-n', '--name'):
-					Args.name = value
-				elif name in ('-p', '--param'):
-					self.param = value
-		except getopt.GetoptError:
-			self.usage()
-	@classmethod
-	def usage(self):
-		print File.read(Dever.path, 'usage')
-		sys.exit()
-
-class Env(object):
-	dm_use = 'base.use'
-	dm_store = 'base.store'
-	dm_val = 'val.'
-	data = {}
-
-	@staticmethod
-	def key(name):
-		return name.split('.')
-
-	@classmethod
-	def init(self, name):
-		if not self.data:
-			self.data = Config.runtime()
-		return self.key(name)
-
-	@classmethod
-	def read(self, name):
-		key, name = self.init(name)
-		if key in self.data and name in self.data[key]:
-			return self.data[key][name]
-		else:
-			return False
-
-	@classmethod
-	def write(self, name, value):
-		key, name = self.init(name)
-		self.data[key][name] = value
-		Config.runtime(key, name, value)
-		return value
-
-	@classmethod
-	def use(self, value=None):
-		if value:
-			return self.write(self.dm_use, value)
-		return self.read(self.dm_use)
-
-	@classmethod
-	def store(self, value=None):
-		if value:
-			return self.write(self.dm_store, value)
-		return self.read(self.dm_store)
-
-	@classmethod
-	def val(self, name='', value=None):
-		name = self.dm_val + name.capitalize()
-		if value:
-			return self.write(name, value)
-		return self.read(name)
-
-class Config(object):
-	@classmethod
-	def runtime(self, key='', name='', value=''):
-		runtime = Dever.path + 'data/runtime.conf'
-		if File.exists(runtime):
-			config = ConfigParser.ConfigParser()
-			config.read(runtime)
-			if key and name:
-				config.set(key, name, value)
-				config.write(open(runtime, 'w'))
-			else:
-				result = {}
-				for item in config.sections():
-					result[item] = self.readOption(config, item)
-				return result
-		else:
-			print runtime + ' is not exists'
-			sys.exit()
-
-	@classmethod
-	def core(self, path):
-		core = Dever.path + path + 'core.conf'
-		if File.exists(core):
-			config = ConfigParser.ConfigParser()
-			config.read(core)
-			result = {}
-			for item in config.sections():
-				result[item] = self.readOption(config, item)
-			return result
-		else:
-			print core + ' is not exists'
-			sys.exit()
-
-	@classmethod
-	def read(self, path):
-		if '-' in Args.name:
-			temp = Args.name.split('-')
-			Args.name = temp[0]
-			Args.index = temp[1]
-
-		filename = Dever.path + path + 'conf/' + Args.name + '.conf'
-		if File.exists(filename):
-			config = ConfigParser.ConfigParser()
-			config.read(filename)
-			result = {}
-			result['server'] = []
-			result['config'] = {}
-			result['base'] = {}
-			for item in config.sections():
-				if item == 'base':
-					result['base'] = self.readOption(config, item)
-				else:
-					result['server'].append(item)
-					result['config'][item] = self.readOption(config, item)
-
-			result['base']['path'] = Dever.replace('{base}', Dever.path, result['base']['path'])
-			return result
-		else:
-			print filename + ' is not exists'
-			sys.exit()
+		method = Core.getMethod(Dever_Action, Args.action)
+		method()
 
+class Dever_Action(object):
 	@staticmethod
-	def readOption(config, type):
-		value = config.options(type)
-		result = {}
-		for item in value:
-			result[item] = config.get(type, item)
-		return result
-
-class Alias(object):
-	@classmethod
-	def delete(self, config, name):
-		return
-		result = self.get(config, name)
-		for key in result:
-			action = self.action(name, key)
-			Dever.popen('rm -rf ' + action[1], bg=True)
-			Dever.popen('rm -rf ' + action[2], bg=True)
-	@classmethod
-	def add(self, config, name, content, type):
-		result = self.get(config, name)
-		for key in result:
-			action = self.action(name, key)
-			content = '#!/usr/bin/env sh \nset -e\n'
-			if type != 'call':
-				if action[0] == 'sh':
-					content = content + self.define(name) + \
-						'else\n' + \
-						'docker exec -it ' + name + ' ' + action[0] + ' $@\n' + \
-						'fi'
-				else:
-					content = content + 'docker exec -it ' + name + ' ' + action[0] + ' $@'
-			else:
-				content = content + ' $@'
-			File.write(action[1], content)
-			Dever.popen('ln -sf ' + action[1] + ' ' + action[2])
-
-	@staticmethod
-	def define(name):
-		conf = ['logs', 'inspect', 'restart', 'stop', 'rm', 'rmb', 'run', 'uprun', 'show']
-		result = ''
-		for key in conf:
-			control = 'elif'
-			shell = 'dm ' + key + ' ' + name + '\n'
-			if key == 'logs':
-				control = 'if'
-			result = result + control + ' [ "$1" = "'+key+'" ];then\n' + shell
-		return result
-	@classmethod
-	def get(self, config, name):
-		self.path = Dever.path + 'data/alias/'
-		result = []
-		default = 'sh->' + name
-		if 'alias' in config:
-			config['alias'] = config['alias'] + ',' + default
-			if ',' in config['alias']:
-				result = config['alias'].split(',');
-			else:
-				result = [config['alias']]
+	def init():
+		if Args.name:
+			print 'init appname'
 		else:
-			result = [default]
-		return result
-	@classmethod
-	def action(self, name, key):
-		file = key
-		if '->' in key:
-			temp = key.split('->')
-			key = temp[0]
-			file = temp[1]
-		link = '/usr/bin/' + file
-		file = self.path + file
-		return [key, file, link]
-
-class File(object):
-	@staticmethod
-	def write(file, content):
-		handle = open(file, 'w')
-		handle.write(content)
-		handle.close()
-		Dever.popen('chmod +x ' + file)
-
-	@staticmethod
-	def read(path, name):
-		handle = open(path + name, 'r')
-		content = handle.read()
-		handle.close()
-		return content
-
-	@staticmethod
-	def path():
-		return os.path.split(os.path.realpath(__file__))[0] + '/'
-
-	@staticmethod
-	def exists(name):
-		return os.path.exists(name)
-
-	@staticmethod
-	def rename(old, new):
-		return os.rename(old, new)
-
-	@staticmethod
-	def remove(file):
-		return os.remove(file)
-
-	@staticmethod
-	def mkdir(path):
-		if File.exists(path) == False:
-			os.mkdir(path)
-		return path
+			Core.popen('git clone '+Dever.git+'dever/framework.git ' + Dever.path + 'dever', True)
+			print 'init:yes'
 
 	@staticmethod
-	def mkdirs(path):
-		if File.exists(path) == False:
-			os.makedirs(path)
-		return path
+	def install():
+		print 'install '+Args.name+':yes'
 
-class Dever(object):
-	path = ''
 	@classmethod
-	def getClass(self, name, path=''):
-		obj = self.getObject(name, path)
-		name = name.capitalize()
-		if not hasattr(obj, name):
-			print 'error ' + name
-			sys.exit()
-		return getattr(obj, name)
-
-	@staticmethod
-	def getObject(name, path = ''):
-		return __import__(path + name)
+	def update(self):
+		print 'update '+Args.name+':yes'
 
-	@staticmethod
-	def getMethod(obj, name):
-		if not hasattr(obj, name):
-			print 'error ' + name
-			sys.exit()
-		return getattr(obj, name)
 
-	@classmethod
-	def shell(self, command, sub=False, bg=False):
-		shell = Dever.path + 'src/shell/' + command.replace('.', '/', 1)
-		return self.popen(shell, sub, bg)
-	@staticmethod
-	def popen(command, sub=False, bg=False):
-		string = command
-		if bg == True:
-			command = command + ' 1>/dev/null 2>&1 &'
-		if sub == False:
-			process = os.popen(command)
-			output = process.read()
-			process.close()
-			return output
-		else:
-			popen  = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
-			output = ''
-			print string
-			while True:
-				output = popen.stdout.readline()
-				print output
-				if popen.poll() is not None:
-					break
-			return output
-	@classmethod
-	def install(self, soft):
-		print 'install ' + soft + '...'
-		if soft == 'docker':
-			self.shell('install.docker', True)
-		else:
-			self.shell('install.package ' + soft, True)
-	@classmethod
-	def check(self, soft):
-		result = int(Dever.popen('which '+soft+' | wc -l'))
-		if result != 0:
-			return 1
-		else:
-			self.install(soft)
-			return 0
+class Package(object):
 	@staticmethod
-	def replace(old, new, string):
-		if old in string:
-			string = string.replace(old, new)
-		return string
+	def update():
+		Core.popen('composer.update', True)
 	@staticmethod
-	def isset(v): 
-		try : 
-			type(eval(v))
-		except : 
-			return  0 
-		else : 
-			return  1
+	def install(name):
+		Core.popen('composer.install ' + name, True)
+		print 'finished'

+ 43 - 43
src/docker.py

@@ -5,7 +5,7 @@
     name:docker.py
     author:rabin
 """
-from dever import *
+from core import *
 
 class Docker(object):
 	path = 'src/docker/'
@@ -18,7 +18,7 @@ class Docker(object):
 		self.storeHost = self.core['store'][self.store] + '/'
 
 		action = ('uprun', 'run', 'rm', 'rmb', 'stop', 'create', 'call', 'save', 'load', 'show', 'reset', 'logs', 'restart', 'inspect', 'test')
-		method = Dever.getMethod(Docker_Action, Args.action)
+		method = Core.getMethod(Docker_Action, Args.action)
 		if Args.name and Args.action in action:
 			self.load(method)
 		else:
@@ -94,14 +94,14 @@ class Docker(object):
 					search = re.search(r'\[(.*?)\]', result, re.M|re.I)
 					temp = search.group(1)
 					if temp:
-						result = Dever.replace('['+str(temp)+']', self.name(temp, 1), result)
-				result = Dever.replace('{num}', self.conf['base']['num'], result)
-				result = Dever.replace('{i}', self.conf['base']['i'], result)
-				result = Dever.replace('{path}', self.conf['base']['path'], result)
-				result = Dever.replace('{container}', self.conf['base']['path'] + 'container/', result)
-				result = Dever.replace('{name}', name, result)
+						result = Core.replace('['+str(temp)+']', self.name(temp, 1), result)
+				result = Core.replace('{num}', self.conf['base']['num'], result)
+				result = Core.replace('{i}', self.conf['base']['i'], result)
+				result = Core.replace('{path}', self.conf['base']['path'], result)
+				result = Core.replace('{container}', self.conf['base']['path'] + 'container/', result)
+				result = Core.replace('{name}', name, result)
 				result = self.parse(result)
-				result = Dever.replace(',', ' ' + prefix + ' ', result)
+				result = Core.replace(',', ' ' + prefix + ' ', result)
 				if item == 'hostname':
 					name = result
 
@@ -123,7 +123,7 @@ class Docker(object):
 				if 'http://' not in Args.param:
 					Args.param = 'http://shemic.com/?' + Args.param;
 				if '^' in Args.param:
-					Args.param = Dever.replace('^', '&', Args.param)
+					Args.param = Core.replace('^', '&', Args.param)
 				parse = urlparse.urlparse(Args.param)
 				param = urlparse.parse_qs(parse.query,True)
 
@@ -142,7 +142,7 @@ class Docker(object):
 					print 'please set param value:' + index
 					sys.exit()
 				else:
-					result = Dever.replace('{$'+key+'}', value, result)
+					result = Core.replace('{$'+key+'}', value, result)
 		return result
 
 	@classmethod
@@ -151,15 +151,15 @@ class Docker(object):
 			if ',' in config['rely']:
 				rely = config['rely'].split(',');
 				for i in rely:
-					Dever.popen('dever ' + action + ' ' + i, True)
+					Core.popen('Core ' + action + ' ' + i, True)
 			else:
-				Dever.popen('dever ' + action + ' ' + config['rely'], True)
+				Core.popen('Core ' + action + ' ' + config['rely'], True)
 
 	@classmethod
 	def hook(self, type, config, name):
 		key = 'hook.'+type
 		if key in config:
-			Dever.shell('hook.' + config[key] + ' ' + name + ' ' + Dever.path, bg=True)
+			Core.shell('hook.' + config[key] + ' ' + name + ' ' + Core.path, bg=True)
 
 	@classmethod
 	def slave(self, config, name, action):
@@ -175,7 +175,7 @@ class Docker(object):
 				i = i + 1
 	@classmethod
 	def tar(self, name):
-		path = Dever.path + 'data/backup/' + name + '/'
+		path = Core.path + 'data/backup/' + name + '/'
 		File.mkdir(path)
 		backup = 'backup/' + name
 		tar = path + name + '.tar'
@@ -207,10 +207,10 @@ class Docker_Action(object):
 	@classmethod
 	def login(self):
 		if Args.name and Args.name in Docker.core['store']:
-			Dever.shell('docker.login ' + Docker.core['store'][Args.name], True)
+			Core.shell('docker.login ' + Docker.core['store'][Args.name], True)
 		else:
 			for key,value in Docker.core['store'].items():
-				Dever.shell('docker.login ' + value, True)
+				Core.shell('docker.login ' + value, True)
 
 	@staticmethod
 	def package():
@@ -366,7 +366,7 @@ class Docker_Action(object):
 		state = Container.check(param['name'])
 		if state == 0:
 			Docker.hook('start', param['config'], param['name'])
-			run = ['-it', '--name='+param['name'], '--hostname='+param['name'], restart, daemon, '-v '+Dever.path+'container/share:/share -v /etc/hosts:/etc/hosts.main']
+			run = ['-it', '--name='+param['name'], '--hostname='+param['name'], restart, daemon, '-v '+Core.path+'container/share:/share -v /etc/hosts:/etc/hosts.main']
 
 			args = Container.args()
 			for key in args:
@@ -388,7 +388,7 @@ class Docker_Action(object):
 			if 'test' in param:
 				return 'docker run ' + command
 			print 'setuping ' + param['name'] + ', please wait...'
-			method = Dever.getMethod(Container, param['action'])
+			method = Core.getMethod(Container, param['action'])
 			method(command)
 			Alias.add(param['config'], param['name'], 'docker run ' + command, param['action'])
 			Docker.hook('end', param['config'], param['name'])
@@ -399,11 +399,11 @@ class Container(object):
 	@staticmethod
 	def run(command):
 		command = 'container.run ' + command
-		Dever.shell(command, True, bg=False)
+		Core.shell(command, True, bg=False)
 		return command
 	@staticmethod
 	def show(name=''):
-		print Dever.shell('container.show ' + name)
+		print Core.shell('container.show ' + name)
 	@staticmethod
 	def args():
 		return {
@@ -422,31 +422,31 @@ class Container(object):
 		}
 	@staticmethod
 	def drop():
-		Dever.shell('container.drop', bg=True)
+		Core.shell('container.drop', bg=True)
 	@staticmethod
 	def stop(name):
-		Dever.shell('container.stop ' + name)
+		Core.shell('container.stop ' + name)
 	@staticmethod
 	def logs(name):
-		Dever.shell('container.logs ' + name, True)
+		Core.shell('container.logs ' + name, True)
 	@staticmethod
 	def inspect(name):
-		Dever.shell('container.inspect ' + name, True)
+		Core.shell('container.inspect ' + name, True)
 	@staticmethod
 	def restart(name):
-		Dever.shell('container.restart ' + name)
+		Core.shell('container.restart ' + name)
 	@classmethod
 	def delete(self, name='', bg=False):
 		if name != '':
 			print 'rm ' + name + ', please wait...'
 			if self.check(name) == 1:
-				Dever.shell('container.rm ' + name, False, bg=bg)
+				Core.shell('container.rm ' + name, False, bg=bg)
 		else:
-			Dever.shell('container.rm', False)
+			Core.shell('container.rm', False)
 			
 	@staticmethod
 	def check(name):
-		result = int(Dever.popen('docker ps -a | grep '+name+' | wc -l'))
+		result = int(Core.popen('docker ps -a | grep '+name+' | wc -l'))
 		if result != 0:
 			return 1
 		else:
@@ -454,20 +454,20 @@ class Container(object):
 	@staticmethod
 	def network(config):
 		if 'network' in config:
-			result = int(Dever.popen('docker network ls | grep ' + config['network'] + ' | wc -l'))
+			result = int(Core.popen('docker network ls | grep ' + config['network'] + ' | wc -l'))
 			if result == 0:
-				Dever.shell('container.network ' + config['network'], True)
+				Core.shell('container.network ' + config['network'], True)
 	@staticmethod
 	def save(tar, name, backup):
 		if File.exists(tar) == True:
 			now = time.strftime('%Y%m%d%H%M%S',time.localtime(time.time()))
 			old = replace('.tar', '.' + now + '.tar', tar)
 			File.rename(tar, old)
-		Dever.popen('docker commit -p ' + name + ' ' + backup)
-		Dever.popen('docker save ' + backup + ' > ' + tar, True)
+		Core.popen('docker commit -p ' + name + ' ' + backup)
+		Core.popen('docker save ' + backup + ' > ' + tar, True)
 	@classmethod
 	def load(self, tar, name):
-		Dever.popen('docker load < ' + tar, True)
+		Core.popen('docker load < ' + tar, True)
 		self.delete(name)
 
 class Image(object):
@@ -476,27 +476,27 @@ class Image(object):
 		store = stores[0]
 		if self.check(store) == 1:
 			del stores[0]
-			Dever.shell('image.push ' + store, bg=True)
+			Core.shell('image.push ' + store, bg=True)
 			for value in stores:
 				#print store + ' ' + value
-				Dever.shell('image.push ' + store + ' ' + value, bg=True)
+				Core.shell('image.push ' + store + ' ' + value, bg=True)
 	@staticmethod
 	def show():
-		print Dever.shell('image.show')
+		print Core.shell('image.show')
 	@staticmethod
 	def drop(name=''):
-		Dever.shell('image.drop ' + name, bg=True)
+		Core.shell('image.drop ' + name, bg=True)
 	@staticmethod
 	def delete():
-		Dever.shell('image.rm', bg=True)
+		Core.shell('image.rm', bg=True)
 	@staticmethod
 	def build(path, name):
-		file = Dever.path + Docker.path + 'build/' + name + '/'
+		file = Core.path + Docker.path + 'build/' + name + '/'
 		name = path + name
-		Dever.shell('image.build ' + name + ' ' + file, True)
+		Core.shell('image.build ' + name + ' ' + file, True)
 	@staticmethod
 	def check(name):
-		result = int(Dever.popen('docker images | grep '+name+' | wc -l'))
+		result = int(Core.popen('docker images | grep '+name+' | wc -l'))
 		if result != 0:
 			return 1
 		else:
@@ -505,5 +505,5 @@ class Image(object):
 	def install(library, key):
 		pull = 'docker pull';
 		command = pull + ' ' + library + key
-		Dever.popen(command, True)
+		Core.popen(command, True)
 		print 'finished'

+ 8 - 8
src/main.py

@@ -34,7 +34,7 @@
 	dm install passport 安装官方passport
 
 """
-from dever import *
+from core import *
 class Main(object):
 	use = 'docker'
 	def __new__(cls, *args, **kwargs):
@@ -46,7 +46,7 @@ class Main(object):
 
 	@classmethod
 	def init(self):
-		Dever.path = File.path().replace('/src/', '/')
+		Core.path = File.path().replace('/src/', '/')
 		Args.init()
 		method = ('use', 'set', 'val', 'up', 'commit', 'path', 'shell')
 		if Args.action in method:
@@ -55,12 +55,12 @@ class Main(object):
 			use = Env.use()
 			if not use:
 				use = Env.use(self.use)
-			cls = Dever.getClass(use)
+			cls = Core.getClass(use)
 			cls.init()
 
 	@classmethod
 	def handle(self):
-		method = Dever.getMethod(Main_Action, Args.action)
+		method = Core.getMethod(Main_Action, Args.action)
 		method()
 
 class Main_Action(object):
@@ -91,19 +91,19 @@ class Main_Action(object):
 	@staticmethod
 	def up():
 		print 'loading...'
-		Dever.shell('git.pull ' + Dever.path)
+		Core.shell('git.pull ' + Core.path)
 		print 'dm update success!'
 
 	@staticmethod
 	def commit():
-		print Dever.shell('git.push ' + Dever.path)
+		print Core.shell('git.push ' + Core.path)
 
 	@staticmethod
 	def path():
-		print Dever.path
+		print Core.path
 
 	@staticmethod
 	def shell():
-		print Dever.shell(Args.name)
+		print Core.shell(Args.name)
 
 Main.init()

+ 4 - 4
src/php.py

@@ -5,14 +5,14 @@
     name:php.py
     author:rabin
 """
-from dever import *
+from core import *
 
 class Php(object):
 	path = 'src/php/'
 	share = '/share/lib/php'
 	@classmethod
 	def init(self):
-		method = Dever.getMethod(Php_Action, Args.action)
+		method = Core.getMethod(Php_Action, Args.action)
 		method()
 
 class Php_Action(object):
@@ -29,8 +29,8 @@ class Php_Action(object):
 class Composer(object):
 	@staticmethod
 	def update():
-		Dever.popen('composer.update', True)
+		Core.popen('composer.update', True)
 	@staticmethod
 	def install(name):
-		Dever.popen('composer.install ' + name, True)
+		Core.popen('composer.install ' + name, True)
 		print 'finished'