r84634 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84633‎ | r84634 | r84635 >
Date:21:39, 23 March 2011
Author:diederik
Status:deferred
Tags:
Comment:
Made some minor changes that allow you to install Wikilytics in any location.
Modified paths:
  • /trunk/tools/editor_trends/__init__.py (modified) (history)
  • /trunk/tools/editor_trends/classes/settings.py (modified) (history)
  • /trunk/tools/editor_trends/requirements.txt (modified) (history)

Diff [purge]

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 @@
119119 else:
120120 return False
121121
 122+
122123 def determine_working_directory(self):
123124 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)
126130 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.'
128140
129141 def detect_python_version(self):
130142 version = sys.version_info[0:2]
131 - #logger.debug('Python version: %s' % '.'.join(str(version)))
132143 if version < self.minimum_python_version:
133144 raise exceptions.OutDatedPythonVersionError
134145
Index: trunk/tools/editor_trends/requirements.txt
@@ -1,6 +1,4 @@
22 progressbar==2.3-dev
3 -psyco==1.6
4 -pywin32==214
53 pymongo==1.9
64 argparse
75 python-dateutil

Status & tagging log