Browse Source

Merge branch 'master' of ssh://git.dever.cc:10022/python/demeter

dever 4 years ago
parent
commit
a246ed3baa
2 changed files with 9 additions and 5 deletions
  1. 7 4
      demeter/core.py
  2. 2 1
      demeter/mqtt.py

+ 7 - 4
demeter/core.py

@@ -62,8 +62,9 @@ class Demeter(object):
 
 	@classmethod
 	def initConfig(self):
-		self.path = File.path()
-		self.root = File.cur_path()
+		if not self.path:
+			self.path = File.path()
+			self.root = File.cur_path()
 		if self.config == {}:
 			filename = self.path + 'conf/'+self.getConfigName()+'.conf'
 			if File.exists(filename):
@@ -74,8 +75,10 @@ class Demeter(object):
 					self.config[item] = self.readConfig(config, item)
 				return True
 			else:
-				Demeter.echo(filename + ' is not exists')
-				sys.exit()
+				self.path = self.path + '../'
+				return self.initConfig()
+				#Demeter.echo(filename + ' is not exists')
+				#sys.exit()
 
 	@classmethod
 	def getConfigName(self):

+ 2 - 1
demeter/mqtt.py

@@ -52,7 +52,8 @@ class Connect(object):
 		client.subscribe(key)
 
 	def handle(self, key, value):
-		Demeter.record(key, value)
+		service = Demeter.service('record', 'mqtt')
+		service.push(key, value)
 
 
 class Pub(object):