rabin 2 months ago
parent
commit
7a7177f7e0
2 changed files with 14 additions and 7 deletions
  1. 9 1
      demeter/core.py
  2. 5 6
      demeter/web.py

+ 9 - 1
demeter/core.py

@@ -308,7 +308,7 @@ class Demeter(object):
 
 	@classmethod
 	def hash(self):
-		return self.md5(str(time.clock()))
+		return self.md5(str(time.perf_counter()))
 
 	@classmethod
 	def uuid(self, value):
@@ -606,6 +606,14 @@ class File(object):
 	def runtime(self, path = 'data'):
 		return self.mkdir(self.path() + 'runtime/' + path + '/')
 
+	@classmethod
+	def dest(self, path, name, size = 2, total = 6):
+		data = [name[i:i+size] for i in range(0, total, size)]
+		for key, value in enumerate(data):
+			path = path + value + '/'
+		path = self.mkdirs(path)
+		return path + name
+
 	"""
 	实现 tail -n
 	"""

+ 5 - 6
demeter/web.py

@@ -319,14 +319,13 @@ class Web(object):
 			asyncio.set_event_loop(asyncio.new_event_loop())
 		if settings['debug'] == True:
 			application.listen(settings['port'])
-			tornado.ioloop.IOLoop.instance().start()
 		else:
 			server = tornado.httpserver.HTTPServer(application, settings['max_buffer_size'])
 			server.bind(settings['port'])
 			server.start(settings['process'])
-			try:		
-				Demeter.echo('running on port %s' % settings['port'])
-				tornado.ioloop.IOLoop.instance().start()
+		try:		
+			Demeter.echo('running on port %s' % settings['port'])
+			tornado.ioloop.IOLoop.instance().start()
 
-			except KeyboardInterrupt:
-				tornado.ioloop.IOLoop.instance().stop()
+		except KeyboardInterrupt:
+			tornado.ioloop.IOLoop.instance().stop()