def getLocalAccessPath(self): # TODO: wipe cache if root element and first export ok src = str() local_access_path = os.path.join( self.rspec_cache_dir, os.path.basename(self.getHref())) if not os.path.exists(self.rspec_cache_dir): os.makedirs(self.rspec_cache_dir) if self.rcs == None: if not os.path.exists( local_access_path ): infoMessage("No RCS specified for RSpec '%s', attempting regular file access"\ %(self.getHref()), 4) if not os.path.exists(self.href): userErrorExit("RSpec unreachable with regular file access: \n %s"%(self.href)) shutil.copyfile( self.getHref(), local_access_path ) # access the local rspec if accessable # otherwise the user may be confused why changes in a locally modified would not be applied. if os.path.exists(self.href): local_access_path = self.getHref() else: if self.updating == True or not os.path.exists( local_access_path ): temp_dir = getUserTempDir() rspec_name = os.path.basename(self.getHref()) temp_rspec = os.path.join( temp_dir, rspec_name ) infoMessage("Downloading (svn-exporting) RSpec from '%s' to '%s' using RCS '%s'"\ %(str(self.getHref()), str(temp_rspec), str(self.rcs)), 1) if os.path.exists(temp_rspec): os.remove( temp_rspec ) # rspec access is still handled by svn if self.rcs == 'svn' or self.rcs == 'git': svn = ctx_svn_client.CTXSubversionClient() # does this fail if rspec cannot be fetched? svn.export( self.getHref(), temp_dir, self.revision ) if not os.path.exists( os.path.join(temp_dir, os.path.basename(self.getHref()))): userErrorExit("RSpec unreachable with remote Subversion access: \n %s"%(self.getHref())) else: userErrorExit("Unsupported RCS: %s"%(self.rcs)) src = os.path.join( temp_dir, rspec_name) shutil.copyfile( src, local_access_path ) infoMessage("RSpec local access path resolved to: %s"\ %(local_access_path), 4) return local_access_path
def getLocalAccessPath(self): local_access_path = None if self.rcs == None: infoMessage("No RCS specified for RSpec '%s', attempting regular file access"\ %(self.getHref()), 4) if not os.path.exists(self.href): userErrorExit("RSpec unreachable with regular file access: \n %s"%(self.href)) local_access_path = self.getHref() else: temp_dir = getUserTempDir() rspec_name = os.path.basename(self.getHref()) temp_rspec = os.path.join( temp_dir, rspec_name ) infoMessage("Downloading (svn-exporting) RSpec from '%s' to '%s' using RCS '%s'"\ %(str(self.getHref()), str(temp_rspec), str(self.rcs)), 1) if os.path.exists(temp_rspec): os.remove( temp_rspec ) # rspec access is still handled by svn if self.rcs == 'svn' or self.rcs == 'git': svn = ctx_svn_client.CTXSubversionClient() svn.export( self.getHref(), temp_dir, self.revision ) local_access_path = temp_rspec #elif self.rcs == 'git': #git = ctx_git_client.CTXGitClient() else: userErrorExit("Unsupported RCS: %s"%(self.rcs)) infoMessage("RSpec local access path resolved to: %s"\ %(local_access_path), 4) return local_access_path
def is_time_to_update( interval ): import cPickle import datetime contexo_cfg_dir = getUserTempDir () # # load last update # date_file = os.path.join ( contexo_cfg_dir, "date_file.ctx" ) if os.path.exists ( date_file ): f = open ( date_file, 'rb' ) date = cPickle.load ( f ) f.close () if datetime.date.today() - date < datetime.timedelta (interval): return False else: os.remove ( date_file ) f = open ( date_file, 'wb' ) cPickle.dump ( datetime.date.today(), f ) f.close () return True