rabin 7 years ago
parent
commit
a29bddf0cc
3 changed files with 22 additions and 1 deletions
  1. 21 0
      core.py
  2. 0 1
      model.py
  3. 1 0
      web.py

+ 21 - 0
core.py

@@ -26,6 +26,15 @@ class Demeter(object):
 	def __init__(self):
 		pass
 
+	@staticmethod
+	def isset(v): 
+		try :
+			type (eval(v))
+		except :
+			return 0
+		else : 
+			return 1
+
 	@classmethod
 	def initConfig(self):
 		self.path = File.path()
@@ -169,6 +178,8 @@ class Demeter(object):
 
 	@staticmethod
 	def mktime(value, string='%Y-%m-%d %H:%M:%S'):
+		if ' ' in string and ' ' not in value:
+			value = value + ' 00:00:00'
 		return int(time.mktime(time.strptime(value,string)))
 
 	@staticmethod
@@ -187,6 +198,16 @@ class Demeter(object):
 			return result
 		return result
 
+	@staticmethod
+	def compressUuid(value):
+		row = value.replace('-', '')
+		code = ''
+		hash = [x for x in "0123456789-abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
+		for i in xrange(10):
+			enbin = "%012d" % int(bin(int(row[i * 3] + row[i * 3 + 1] + row[i * 3 + 2], 16))[2:], 10)
+			code += (hash[int(enbin[0:6], 2)] + hash[int(enbin[6:12], 2)])
+		return code
+
 	@staticmethod
 	def error(string):
 		print string

+ 0 - 1
model.py

@@ -10,7 +10,6 @@ import uuid
 import short_url
 import json
 import traceback
-import uuid
 import re
 import math
 from demeter.core import *

+ 1 - 0
web.py

@@ -228,6 +228,7 @@ class Web(object):
 		handlers = []
 		def application_setting():
 			handlers.append((r"/upload/(.*)", tornado.web.StaticFileHandler, {"path": Demeter.path + 'runtime/upload/'}))
+			handlers.append((r"/qrcode/(.*)", tornado.web.StaticFileHandler, {"path": Demeter.path + 'runtime/qrcode/'}))
 			handlers.append((r"/camera/(.*)", tornado.web.StaticFileHandler, {"path": Demeter.path + 'runtime/camera/'}))
 			handlers.append((r"/static/(.*)", tornado.web.StaticFileHandler, {"path":"static"}))
 			handlers.append((r"/(apple-touch-icon\.png)", tornado.web.StaticFileHandler, dict(path=settings['static_path'])))