Browse Source

Code cleaning on the run.py module

Roland Haroutiounian 8 years ago
parent
commit
7d97a15a10
2 changed files with 10 additions and 8 deletions
  1. 9
    0
      lodel/utils/datetime.py
  2. 1
    8
      run.py

+ 9
- 0
lodel/utils/datetime.py View File

1
+# -*- coding: utf-8 -*-
2
+import datetime
3
+
4
+
5
+def get_utc_timestamp():
6
+    d = datetime.datetime.utcnow()
7
+    epoch = datetime.datetime(1970, 1, 1)
8
+    t = (d - epoch).total_seconds()
9
+    return t

+ 1
- 8
run.py View File

1
 # -*- coding: utf-8 -*-
1
 # -*- coding: utf-8 -*-
2
 import os
2
 import os
3
-import datetime
4
 from werkzeug.contrib.sessions import FilesystemSessionStore
3
 from werkzeug.contrib.sessions import FilesystemSessionStore
5
 
4
 
6
 from lodel.interface.web.router import get_controller
5
 from lodel.interface.web.router import get_controller
7
 from lodel.interface.web.lodelrequest import LodelRequest
6
 from lodel.interface.web.lodelrequest import LodelRequest
7
+from lodel.utils.datetime import get_utc_timestamp
8
 
8
 
9
 # TODO Déplacer ces trois paramètres dans les settings
9
 # TODO Déplacer ces trois paramètres dans les settings
10
 SESSION_FILES_TEMPLATE = 'lodel_%s.sess'
10
 SESSION_FILES_TEMPLATE = 'lodel_%s.sess'
13
 
13
 
14
 session_store = FilesystemSessionStore(path=SESSION_FILES_BASE_DIR, filename_template=SESSION_FILES_TEMPLATE)
14
 session_store = FilesystemSessionStore(path=SESSION_FILES_BASE_DIR, filename_template=SESSION_FILES_TEMPLATE)
15
 
15
 
16
-# TODO Déplacer cette méthode dans un module Lodel/utils/datetime.py
17
-def get_utc_timestamp():
18
-    d = datetime.datetime.utcnow()
19
-    epoch = datetime.datetime(1970, 1, 1)
20
-    t = (d - epoch).total_seconds()
21
-    return t
22
-
23
 # TODO déplacer dans un module "sessions.py"
16
 # TODO déplacer dans un module "sessions.py"
24
 def delete_old_session_files(timestamp_now):
17
 def delete_old_session_files(timestamp_now):
25
     session_files_path = os.path.abspath(session_store.path)
18
     session_files_path = os.path.abspath(session_store.path)

Loading…
Cancel
Save