Changeset 179
- Timestamp:
- 07/22/08 15:07:27 (5 months ago)
- Files:
-
- trunk/src/facets/fkbtools.py (modified) (3 diffs)
- trunk/src/facets/srblib.py (modified) (2 diffs)
- trunk/src/spikes.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/facets/fkbtools.py
r176 r179 23 23 import tables 24 24 import logging 25 import time 25 26 26 27 def getFromURL(url): … … 40 41 Return the temporary directory. 41 42 """ 42 logging.debug(' getZipURL("%s")' % url) 43 localfilepath = getFromURL(url) 44 tmpdir = os.path.dirname(localfilepath) 45 logging.debug(' run process: "unzip -o -q %s -d %s"' % (localfilepath,tmpdir)) 46 p = subprocess.Popen("unzip -o -q %s -d %s" % (localfilepath,tmpdir), shell=True, 47 stdout=subprocess.PIPE, stderr=subprocess.PIPE) 48 success = p.wait() 43 TIMEOUT = 30 # seconds 44 SLEEP = 1 # seconds 45 success = -1 46 start_time = time.time() 47 while success != 0: 48 if time.time()-start_time > TIMEOUT: 49 raise Exception("Timeout when trying to get zipfile from %s" % url) 50 logging.debug(' getZipURL("%s")' % url) 51 localfilepath = getFromURL(url) 52 tmpdir = os.path.dirname(localfilepath) 53 logging.debug(' run process: "unzip -o -q %s -d %s"' % (localfilepath,tmpdir)) 54 p = subprocess.Popen("unzip -o -q %s -d %s" % (localfilepath,tmpdir), shell=True, 55 stdout=subprocess.PIPE, stderr=subprocess.PIPE) 56 success = p.wait() 57 if success != 0: 58 logging.warning("Problem unzipping file: %s %s.\nRetrying %s." % (p.stdout.read(), p.stderr.read(), url)) 59 time.sleep(SLEEP) 60 SLEEP *= 2 49 61 return tmpdir 50 62 … … 149 161 pass 150 162 tmpdir = getZipURL(url) 151 topdir = os.path.join(tmpdir,[f for f in os.listdir(tmpdir) if f.find(".zip") < 0 and f.find("MACOSX") < 0][0]) 152 153 163 dirlist = [f for f in os.listdir(tmpdir) if f.find(".zip") < 0 and f.find("MACOSX") < 0] 164 if len(dirlist) == 1: 165 topdir = os.path.join(tmpdir, dirlist[0]) 166 else: 167 raise Exception("Problem obtaining stimulus. Contents of %s: %s" % (tmpdir, os.listdir(tmpdir))) 154 168 frame_list = (os.path.join(topdir,"frames"),topdir) 155 169 f = open(os.path.join(topdir,"parameters"),'r') # parameteters should contain the frame_duration parameter trunk/src/facets/srblib.py
r176 r179 168 168 def close(self): 169 169 srb.obj_close(self.server.cid,self.srb_fid) 170 171 172 170 173 171 174 172 except ImportError: … … 216 214 print ('sending request /SRB/SRBManageFiles?action=getChildren&subDir=%s/%s' % (self._root,self.pwd)) 217 215 conn.putheader('Accept', 'text/html') 218 conn.putheader('Accept', 'text/xml')216 conn.putheader('Accept', 'text/xml') 219 217 conn.putheader('Accept', 'text/plain') 220 218 conn.putheader("Authorization",self._auth) trunk/src/spikes.py
r157 r179 344 344 for id,spikes in self.spiketrains.items(): # 345 345 self.spiketrains[id] = SpikeTrain(spike_times=spikes, dt=self.dt, t_start=self.t_start, t_stop=self.t_stop) 346 if self.t_start is None or self.t_stop is None:346 if len(self) > 0 and (self.t_start is None or self.t_stop is None): 347 347 self.__calc_startstop() 348 348 … … 373 373 assert isinstance(val, SpikeTrain), "A SpikeList object can only contain SpikeTrain objects" 374 374 self.spiketrains[i] = val 375 self.id_list.append(i) 375 376 self.__calc_startstop() 376 377

