def do_pymongo(self): #debug ''' self.debug(('self.',self,[ 'PymongoingUrlStr' ])) ''' #folder self.folder() #import ''' self.debug('import pymongo') ''' #kill all a possible old mongod process if self.PymongoingKillBool: #status PymongoneIdStr=SYS.status( 'mongod' ) #debug ''' self.debug('PymongoneIdStr is '+PymongoneIdStr) ''' #Check if PymongoneIdStr!="": #kill os.popen( 'kill '+PymongoneIdStr ) #connect try: #import ''' self.debug('import pymongo') ''' #import from pymongo import MongoClient #debug ''' self.debug('try to connect to MongoClient') ''' #init self.PymongoneClientVariable=MongoClient(self.PymongoingUrlStr) except: #debug ''' self.debug('No connection maybe to pymongo') ''' #set self.PymongoneFolderPathStr=self.FolderingPathVariable+'data/db/' #Check if os.path.isdir(self.PymongoneFolderPathStr)==False: os.popen('mkdir '+self.FolderingPathVariable+'data') os.popen('mkdir '+self.FolderingPathVariable+'data/db') #popen self.process( '/usr/local/bin/mongod --dbpath '+self.PymongoneFolderPathStr, True ) #debug ''' self.debug( ('self.',self,['ProcessedPopenVariable']) ) ''' #wait for connect import time PymongoneConnectBool=False PymongoneCountInt=0 while PymongoneConnectBool==False and PymongoneCountInt<5: try: #connect self.PymongoneClientVariable=MongoClient(self.PymongoingUrlStr) #Check if self.PymongoneClientVariable!=None: PymongoneConnectBool=True except: #debug ''' self.debug( [ 'Connection to MongoClient failed at the PymongoneCountInt='+str( PymongoneCountInt), ('self.',self,['PymongoneClientVariable']) ] ) ''' #say that it is not setted PymongoneConnectBool=False PymongoneCountInt+=1 time.sleep(0.2) #debug '''