Index: trunk/tools/editor_trends/__init__.py |
— | — | @@ -1,30 +0,0 @@ |
2 | | -import os |
3 | | -import sys |
4 | | - |
5 | | -from classes import singleton |
6 | | - |
7 | | -class Path: |
8 | | - __metaclass__ = singleton.Singleton |
9 | | - |
10 | | - def __init__(self): |
11 | | - self.cwd = self.determine_working_directory() |
12 | | - self.update_python_path() |
13 | | - |
14 | | - def determine_working_directory(self): |
15 | | - cwd = os.getcwd() |
16 | | - if not cwd.endswith('editor_trends%s' % os.sep): |
17 | | - pos = cwd.find('editor_trends') + 14 |
18 | | - cwd = cwd[:pos] |
19 | | - return cwd |
20 | | - |
21 | | - def update_python_path(self): |
22 | | - IGNORE_DIRS = ['wikistats', 'zips', 'datasets', 'mapreduce', 'logs', |
23 | | - 'statistics', 'js_scripts', 'deployment', |
24 | | - 'documentation', 'data', 'code-snippets'] |
25 | | - dirs = [name for name in os.listdir(self.cwd) if |
26 | | - os.path.isdir(os.path.join(self.cwd, name))] |
27 | | - for subdirname in dirs: |
28 | | - if not subdirname.startswith('.') and subdirname not in IGNORE_DIRS: |
29 | | - sys.path.append(os.path.join(self.cwd, subdirname)) |
30 | | - |
31 | | -Path() |
Index: trunk/tools/editor_trends/classes/settings.py |
— | — | @@ -118,16 +118,27 @@ |
119 | 119 | else: |
120 | 120 | return False |
121 | 121 | |
| 122 | + |
122 | 123 | def determine_working_directory(self): |
123 | 124 | cwd = os.getcwd() |
124 | | - if not cwd.endswith('editor_trends%s' % os.sep): |
125 | | - pos = cwd.find('editor_trends') + 14 |
| 125 | + slashes = cwd.count(os.sep) |
| 126 | + paths = [] |
| 127 | + paths.append(cwd) |
| 128 | + while slashes >0 : |
| 129 | + pos = cwd.rfind(os.sep) |
126 | 130 | cwd = cwd[:pos] |
127 | | - return cwd |
| 131 | + if cwd != '': |
| 132 | + paths.append(cwd) |
| 133 | + slashes -=1 |
| 134 | + for cwd in paths: |
| 135 | + for root, dirs, files in os.walk(cwd, topdown=True): |
| 136 | + if os.path.exists(os.path.join(root, 'manage.py')): |
| 137 | + return root |
| 138 | + |
| 139 | + raise 'I could not determine the location of manage.py, please reinstall Wikilytics.' |
128 | 140 | |
129 | 141 | def detect_python_version(self): |
130 | 142 | version = sys.version_info[0:2] |
131 | | - #logger.debug('Python version: %s' % '.'.join(str(version))) |
132 | 143 | if version < self.minimum_python_version: |
133 | 144 | raise exceptions.OutDatedPythonVersionError |
134 | 145 | |
Index: trunk/tools/editor_trends/requirements.txt |
— | — | @@ -1,6 +1,4 @@ |
2 | 2 | progressbar==2.3-dev |
3 | | -psyco==1.6 |
4 | | -pywin32==214 |
5 | 3 | pymongo==1.9 |
6 | 4 | argparse |
7 | 5 | python-dateutil |