From: <zk...@us...> - 2010-02-12 16:22:13
|
Revision: 667 http://pyphant.svn.sourceforge.net/pyphant/?rev=667&view=rev Author: zklaus Date: 2010-02-12 16:21:58 +0000 (Fri, 12 Feb 2010) Log Message: ----------- Merge branch 'master' into svn-trunk * master: Fix: Path issues on Windows machines Fix: KMVisualizer Modified Paths: -------------- trunk/src/pyphant/pyphant/core/Helpers.py trunk/src/pyphant/pyphant/core/KnowledgeManager.py trunk/src/pyphant/pyphant/core/KnowledgeNode.py trunk/src/pyphant/pyphant/core/WebInterface.py trunk/src/pyphant/pyphant/visualizers/KMVisualizer.py trunk/src/pyphant/pyphant/wxgui2/wxPyphantApplication.py Modified: trunk/src/pyphant/pyphant/core/Helpers.py =================================================================== --- trunk/src/pyphant/pyphant/core/Helpers.py 2010-02-05 14:37:50 UTC (rev 666) +++ trunk/src/pyphant/pyphant/core/Helpers.py 2010-02-12 16:21:58 UTC (rev 667) @@ -29,7 +29,7 @@ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -def getPyphantPath(subdir = '/'): +def getPyphantPath(subdir = ''): """ returns full pyphant path with optional subdirectory subdir -- subdirectory that is created if it does not exist already, @@ -37,20 +37,11 @@ """ import os homedir = os.path.expanduser('~') - if not subdir.startswith('/'): - subdir = '/' + subdir - if not subdir.endswith('/'): - subdir = subdir + '/' if homedir == '~': homedir = os.getcwdu() - plist = ('/.pyphant' + subdir).split('/') - makedir = homedir - path = homedir + '/.pyphant' + subdir - for p in plist: - if p != '': - makedir += "/%s" % (p, ) - if not os.path.isdir(makedir): - os.mkdir(makedir) + path = os.path.join(homedir, '.pyphant', subdir) + if not os.path.isdir(path): + os.makedirs(path) return path def getUsername(): Modified: trunk/src/pyphant/pyphant/core/KnowledgeManager.py =================================================================== --- trunk/src/pyphant/pyphant/core/KnowledgeManager.py 2010-02-05 14:37:50 UTC (rev 666) +++ trunk/src/pyphant/pyphant/core/KnowledgeManager.py 2010-02-12 16:21:58 UTC (rev 667) @@ -58,7 +58,7 @@ CACHE_MAX_SIZE = 256 * 1024 * 1024 # Limit for number of stored DCs in cache: CACHE_MAX_NUMBER = 100 -KM_PATH = '/KMstorage/' +KM_PATH = 'KMstorage' REHDF5 = re.compile(r'..*\.h5$|..*\.hdf$|..*\.hdf5$') REFMF = re.compile(r'..*\.fmf$') @@ -67,18 +67,17 @@ Returns a unique filename for the given emd5. """ emd5list = urlparse(dcId + '.h5')[2][2:].split('/') - emd5path = '' - for p in emd5list[:-2]: - emd5path += (p + '/') - emd5path += emd5list[-2][:10] + '/' + emd5list[-2][11:]\ - + '.' + emd5list[-1] + emd5path = os.path.join( + *(emd5list[:-2] + [emd5list[-2][:10], + emd5list[-2][11:] + '.' + emd5list[-1]])) directory = os.path.dirname(emd5path) filename = os.path.basename(emd5path) if temporary: - subdir = 'tmp/by_emd5/' + subdir = os.path.join('tmp', 'by_emd5') else: - subdir = 'by_emd5/' - return getPyphantPath(KM_PATH + subdir + directory) + filename + subdir = 'by_emd5' + return os.path.join(getPyphantPath( + os.path.join(KM_PATH, subdir, directory)), filename) class DCNotFoundError(Exception): @@ -157,7 +156,8 @@ self._cache = [] self._cache_size = 0 if KM_DBASE == u'default': - self.dbase = getPyphantPath('/sqlite3/') + "km_meta.sqlite3" + self.dbase = os.path.join(getPyphantPath('sqlite3'), + "km_meta.sqlite3") else: self.dbase = KM_DBASE self.any_value = AnyValue() @@ -165,7 +165,7 @@ wrapper.setup_dbase() self.node = None # for hooking up a KnowledgeNode self.uuid = uuid1().urn - tmpdir = getPyphantPath(KM_PATH + 'tmp/') + tmpdir = getPyphantPath(os.path.join(KM_PATH, 'tmp')) if os.path.isdir(tmpdir): from shutil import rmtree try: @@ -222,11 +222,11 @@ parsed = urlparse(url) tmp_extension = '' if temporary: - tmp_extension = 'tmp/' - filename = KM_PATH + tmp_extension + 'registered/' + parsed[1] + '/' - filename += os.path.basename(parsed[2]) - directory = os.path.dirname(filename) - filename = getPyphantPath(directory) + os.path.basename(filename) + tmp_extension = 'tmp' + directory = os.path.join(KM_PATH, tmp_extension, + 'registered', parsed[1]) + filename = os.path.join(getPyphantPath(directory), + os.path.basename(parsed[2])) if os.path.exists(filename): i = 0 directory = os.path.dirname(filename) @@ -239,7 +239,8 @@ from sys import maxint while i < maxint: fill = str(i).zfill(10) - tryfn = "%s/%s%s.%s" % (directory, fnwoext, fill, ext) + tryfn = os.path.join(directory, + "%s%s.%s" % (fnwoext, fill, ext)) if os.path.exists(tryfn): i += 1 else: Modified: trunk/src/pyphant/pyphant/core/KnowledgeNode.py =================================================================== --- trunk/src/pyphant/pyphant/core/KnowledgeNode.py 2010-02-05 14:37:50 UTC (rev 666) +++ trunk/src/pyphant/pyphant/core/KnowledgeNode.py 2010-02-12 16:21:58 UTC (rev 667) @@ -205,13 +205,14 @@ self.km = local_km self.remotes = [] if dbase == u'default': - self._dbase = getPyphantPath('/sqlite3/') + 'kn_remotes.sqlite3' + self._dbase = os.path.join(getPyphantPath('sqlite3'), + 'kn_remotes.sqlite3') else: self._dbase = dbase self._restore_remotes() self._setup_routes() self._tempdir = mkdtemp(prefix = 'HDF5Wrap') - tpl_path = pyphant_source_path[0] + '/web/templates/' + tpl_path = os.path.join(pyphant_source_path[0], 'web', 'templates') if not tpl_path in pyphant.core.bottle.TEMPLATE_PATH: pyphant.core.bottle.TEMPLATE_PATH.append(tpl_path) from pyphant.core.WebInterface import WebInterface Modified: trunk/src/pyphant/pyphant/core/WebInterface.py =================================================================== --- trunk/src/pyphant/pyphant/core/WebInterface.py 2010-02-05 14:37:50 UTC (rev 666) +++ trunk/src/pyphant/pyphant/core/WebInterface.py 2010-02-12 16:21:58 UTC (rev 667) @@ -49,6 +49,7 @@ from pyphant.core.KnowledgeManager import DCNotFoundError from types import StringTypes from pyphant.core.SQLiteWrapper import SQLiteWrapper +import os def cond(condition, results): @@ -344,7 +345,7 @@ self.enabled = enabled self.kn = knowledge_node from pyphant import __path__ as ppath - self.rootdir = ppath[0] + '/web/' + self.rootdir = os.path.join(ppath[0], 'web') self.url_link = HTMLLink(self.kn.url, self.kn.url).getHTML() self.menu = HTMLTable( [[HTMLLink('/search?shorten=True', 'Browse Data Containers'), @@ -394,13 +395,15 @@ def images(self, filename): if not self.enabled: return template('disabled') - send_file(filename, self.rootdir + 'images/', guessmime=False, + send_file(filename, os.path.join(self.rootdir, 'images'), + guessmime=False, mimetype=self.kn.mimetypes.guess_type(filename)[0]) def script(self, filename): if not self.enabled: return template('disabled') - send_file(filename, self.rootdir + 'script/', guessmime=False, + send_file(filename, os.path.join(self.rootdir, 'script'), + guessmime=False, mimetype='application/javascript') def remote_action(self): @@ -439,7 +442,7 @@ def log(self): if not self.enabled: return template('disabled') - with open(getPyphantPath() + 'pyphant.log') as logfile: + with open(os.path.join(getPyphantPath(), 'pyphant.log')) as logfile: loglines = logfile.readlines() return template('log', loglines=''.join(loglines), url=self.url_link) Modified: trunk/src/pyphant/pyphant/visualizers/KMVisualizer.py =================================================================== --- trunk/src/pyphant/pyphant/visualizers/KMVisualizer.py 2010-02-05 14:37:50 UTC (rev 666) +++ trunk/src/pyphant/pyphant/visualizers/KMVisualizer.py 2010-02-12 16:21:58 UTC (rev 667) @@ -52,10 +52,10 @@ km = KM.getInstance() km.registerDataContainer(DataContainer) dc_id = DataContainer.id - if km.isServerRunning(): - url = 'http://%s:%d/request_dc_details?dcid=%s' % (km._http_host, - km._http_port, - dc_id) + if km.node is not None: + if km.node.app.serve: + url = '%ssummary?id=%s' \ + % (km.node.url, dc_id) webbrowser.open_new_tab(url) else: print "ID of registered DC is: " + dc_id Modified: trunk/src/pyphant/pyphant/wxgui2/wxPyphantApplication.py =================================================================== --- trunk/src/pyphant/pyphant/wxgui2/wxPyphantApplication.py 2010-02-05 14:37:50 UTC (rev 666) +++ trunk/src/pyphant/pyphant/wxgui2/wxPyphantApplication.py 2010-02-12 16:21:58 UTC (rev 667) @@ -39,7 +39,7 @@ import os, os.path, pkg_resources from pyphant.core.Helpers import getPyphantPath -LOGDIR = getPyphantPath()[:-1] +LOGDIR = getPyphantPath() import logging # logging.basicConfig(level=logging.DEBUG) #else: @@ -133,8 +133,8 @@ self.Bind(wx.EVT_SIZE, self.onSize) self.compositeWorkerStack=[] wx.MessageBox("Located log directory at %s.\n" - "Logging will go to %s/pyphant.log." % - (LOGDIR,LOGDIR), + "Logging will go to %s." % + (LOGDIR, os.path.join(LOGDIR, 'pyphant.log')), "Logging info") def _initSash(self): @@ -278,7 +278,6 @@ self.Bind(wx.EVT_MENU, self.onUpdatePyphant, id=nId) return updateMenu - def onUpdatePyphant(self, event): import pyphant.core.UpdateManager pyphant.core.UpdateManager.updatePackage(self.updateIds[event.Id]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |