فهرست منبع

datetime으로 통일 및 기타

ect (or 2du) 8 سال پیش
والد
کامیت
f368e70569
4فایلهای تغییر یافته به همراه8 افزوده شده و 26 حذف شده
  1. 1 15
      app.py
  2. 1 4
      func.py
  3. 1 1
      set_mark/start.py
  4. 5 6
      set_mark/tool.py

+ 1 - 15
app.py

@@ -24,7 +24,7 @@ from func import *
 from set_mark.tool import savemark
 
 # 버전 표기
-r_ver = 'v3.0.4-Beta-' + time.strftime('%y%m%d', time.localtime(os.stat('app.py').st_mtime))
+r_ver = 'v3.0.4-Beta-' + str(int(datetime.datetime.fromtimestamp(os.path.getmtime('app.py')).strftime("%Y%m%d")))
 print('Version : ' + r_ver)
 
 # set.json 설정 확인
@@ -64,9 +64,6 @@ compress = Compress()
 compress.init_app(app)
 
 # 템플릿 설정
-def md5_replace(data):
-    return hashlib.md5(data.encode()).hexdigest()       
-
 app.jinja_env.filters['md5_replace'] = md5_replace
 app.jinja_env.filters['load_lang'] = load_lang
 
@@ -180,9 +177,6 @@ else:
 json_data = open(os.path.join('language', rep_language + '.json'), 'rt', encoding='utf-8').read()
 lang_data = json.loads(json_data)
 
-# 한번 개행
-print('')
-
 # 호환성 설정
 try:
     curs.execute("alter table history add hide text default ''")
@@ -1006,8 +1000,6 @@ def indexing():
     if admin_check(None, 'indexing') != 1:
         return re_error('/error/3')
 
-    print('')
-
     curs.execute("select name from sqlite_master where type = 'index'")
     data = curs.fetchall()
     if data:
@@ -1039,8 +1031,6 @@ def indexing():
 
     conn.commit()
     
-    print('')
-
     return redirect('/')        
 
 @app.route('/re_start')
@@ -1048,9 +1038,7 @@ def re_start():
     if admin_check(None, 're_start') != 1:
         return re_error('/error/3')
 
-    print('')
     print('Re Start')
-    print('')
 
     os.execl(sys.executable, sys.executable, *sys.argv)
 
@@ -1060,7 +1048,6 @@ def update():
        return re_error('/error/3')
 
     if platform.system() == 'Linux':
-        print('')
         print('Update')
 
         ok = os.system('git pull')
@@ -1068,7 +1055,6 @@ def update():
             return redirect('/re_start')
     else:
         if platform.system() == 'Windows':
-            print('')
             print('Download')
 
             urllib.request.urlretrieve('https://github.com/2DU/openNAMU/archive/stable.zip', 'update.zip')

+ 1 - 4
func.py

@@ -13,10 +13,7 @@ import time
 import os
 
 # 일부 툴 불러옴
-from set_mark.tool import get_time
-from set_mark.tool import ip_check
-from set_mark.tool import url_pas
-from set_mark.tool import sha224
+from set_mark.tool import *
 
 # 나무마크 불러옴
 from mark import *

+ 1 - 1
set_mark/start.py

@@ -633,7 +633,7 @@ def start(conn, data, title):
         
         e_data = old - will
         
-        data = re.sub('\[age\(([0-9]{4})-([0-9]{2})-([0-9]{2})\)\]', str(int(int(e_data.days) / 365)), data, 1)
+        data = re.sub('\[age\(([0-9]{4})-([0-9]{2})-([0-9]{2})\)\]', str(e_data.year), data, 1)
 
     dday_data = re.findall('\[dday\(([0-9]{4}-[0-9]{2}-[0-9]{2})\)\]', data)
     for dday in dday_data:

+ 5 - 6
set_mark/tool.py

@@ -1,16 +1,12 @@
 from flask import session, request
 
 from urllib import parse
-import time
 import datetime
 import re
 import hashlib
 
 def get_time():
-    now = time.localtime()
-    date = "%04d-%02d-%02d %02d:%02d:%02d" % (now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec)
-
-    return date
+    return str(datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S"))
     
 def ip_check():
     if session and ('Now' and 'DREAMER') in session and session['Now'] == 1:
@@ -39,4 +35,7 @@ def url_pas(data):
     return parse.quote(data).replace('/','%2F')
 
 def sha224(data):
-    return hashlib.sha224(bytes(data, 'utf-8')).hexdigest()
+    return hashlib.sha224(bytes(data, 'utf-8')).hexdigest()
+
+def md5_replace(data):
+    return hashlib.md5(data.encode()).hexdigest()