comparison pics2/pics_app.py @ 82:d7d67887102f

move pinlib to a shared location and have pics use it
author paulo
date Wed, 29 Jun 2016 00:11:55 -0700
parents ec48011dca1e
children d521df55f56c
comparison
equal deleted inserted replaced
6:83ab7d740040 7:eb7dadfa4306
6 import random 6 import random
7 import urlparse 7 import urlparse
8 8
9 import html 9 import html
10 10
11 import pinlib
12
11 import logging 13 import logging
12 logging.basicConfig( 14 logging.basicConfig(
13 level=logging.INFO, 15 level=logging.INFO,
14 filename="_LOG", 16 filename="_LOG",
15 format="%(asctime)s %(levelname)-8s %(message)s", 17 format="%(asctime)s %(levelname)-8s %(message)s",
16 ) 18 )
17
18
19 def _lahat():
20 ret = None
21
22 try:
23 with open("_lahat") as lahat_f:
24 ret = lahat_f.read().strip()
25 except IOError:
26 pass
27
28 return ret
29 19
30 20
31 def _is_pics_dir(dirpath): 21 def _is_pics_dir(dirpath):
32 return os.path.exists(os.path.join(dirpath, "_picsroot")) 22 return os.path.exists(os.path.join(dirpath, "_picsroot"))
33 23
150 if len(ppi) < 1 or ppi[0] != '': 140 if len(ppi) < 1 or ppi[0] != '':
151 raise AssertionError("Parsed path length must start empty: " + pi) 141 raise AssertionError("Parsed path length must start empty: " + pi)
152 142
153 self._qs = urlparse.parse_qs(self._environ["QUERY_STRING"]) 143 self._qs = urlparse.parse_qs(self._environ["QUERY_STRING"])
154 logging.debug("self._qs = %s" % self._qs) 144 logging.debug("self._qs = %s" % self._qs)
155 if self._qs.get("lahat", [''])[0] == _lahat(): 145 if pinlib.PinMan("lahat").check(pinlib.parse_cookies(self._environ)):
156 self._show_index = True 146 self._show_index = True
157 147
158 if len(ppi) >= 2 and _is_pics_dir(ppi[1]): 148 if len(ppi) >= 2 and _is_pics_dir(ppi[1]):
159 if len(ppi) == 2: 149 if len(ppi) == 2:
160 self._page_func = self.page_thumbs 150 self._page_func = self.page_thumbs