当前位置: 首页>>代码示例>>Python>>正文


Python Popen.jobid方法代码示例

本文整理汇总了Python中subprocess.Popen.jobid方法的典型用法代码示例。如果您正苦于以下问题:Python Popen.jobid方法的具体用法?Python Popen.jobid怎么用?Python Popen.jobid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在subprocess.Popen的用法示例。


在下文中一共展示了Popen.jobid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: addProcess

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import jobid [as 别名]
	def addProcess(self, job, projectdir, zoomLevels, metatile, extent):
		pprint.pprint("-----------")
		path = os.path.realpath(__file__)
			
		# Create mapcache folder if not exist
		if not os.path.exists(projectdir+"/mapcache"):
			os.makedirs(projectdir+"/mapcache")
		
		#If there is a gitignore file, add the mapcache directory
		if os.path.exists(projectdir+"/.gitignore"):
			with open(projectdir+"/.gitignore", "r+") as gitignore:
				lines = gitignore.readlines()
				found = False
				for line in lines:
					if "mapcache" in line:
						found = True
				if not found:	
					gitignore.writelines("mapcache/*")

		jobdir = projectdir+"/mapcache/job-"+job['title']+str(job['id'])
		os.makedirs(jobdir)
		
		inFile = open(path.replace("processManager.py","mapcacheConfig.xml.default"))
		outFile = open(projectdir+"/mapcacheConfig.xml","w")
		replacements = {'<!--SCRIBEUIPATH-->':jobdir, '<!--SCRIBEUITITLE-->':"job-"+job['title']+str(job['id']), '<!--SCRIBEUIMAPFILEPATH-->':projectdir+'/map/'+job['map_name']+'.map'}

		for line in inFile:
			for src, target in replacements.iteritems():
				line = line.replace(src, target)
			outFile.write(line)
		inFile.close()
		outFile.close()
		#start mapcache
		pprint.pprint("Adding new process")
		p = Popen(["mapcache_seed", "-c", projectdir+"/mapcacheConfig.xml", "-t", "default", "-z", zoomLevels, "-M", metatile, "-e",extent], shell=False)
		p.jobid = job['id']
		
		# Lock the processes list before adding data
		self.lock.acquire()
		self.processes.append(p)

		#If thread is finished, start it up
		if self.thread is None or not self.thread.isAlive():
			self.thread = None
			self.thread = self.pollProcesses(self)
			self.thread.start()
		self.lock.release()
		return
开发者ID:kleopatra999,项目名称:scribeui,代码行数:50,代码来源:processManager.py

示例2: addProcess

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import jobid [as 别名]
    def addProcess(self, job, projectdir, mapfile, zoomLevels, metatile, grid, 
            extent=None, dbconfig=None, jobdir=None, mapserver_url='http://localhost/cgi-bin/mapserv'):
        projectdir = projectdir.rstrip('/')

        pprint.pprint("-----------")
        path = os.path.dirname(os.path.abspath(__file__))

        # Create mapcache folder if not exist
        if not os.path.exists(projectdir+"/mapcache"):
            os.makedirs(projectdir+"/mapcache")
        
        #If there is a gitignore file, add the mapcache directory
        if os.path.exists(projectdir+"/.gitignore"):
            with open(projectdir+"/.gitignore", "r+") as gitignore:
                lines = gitignore.readlines()
                found = False
                for line in lines:
                    if "mapcache" in line:
                        found = True
                if not found:   
                    gitignore.writelines("mapcache/*")

        if not jobdir:
            jobdir = projectdir+"/mapcache/job-"+job.title+str(job.id)
        else:
            jobdir = jobdir.rstrip('/') + '/' + job.title+str(job.id)
        if not os.path.exists(jobdir):
            os.makedirs(jobdir)

        inFile = open(path + "/mapcacheConfig.xml.default")
        outFile = open(jobdir+"/mapcacheConfig.xml","w")
        replacements = {
            '<!--SCRIBEUIPATH-->':jobdir, 
            '<!--SCRIBEUITITLE-->':"job-"+job.title+str(job.id), 
            '<!--SCRIBEUIMAPFILEPATH-->':mapfile,
            '<!--SCRIBEUIMAPSERVER-->':mapserver_url
        }

        for line in inFile:
            for src, target in replacements.iteritems():
                line = line.replace(src, target)
            outFile.write(line)
        inFile.close()
        outFile.close()

        pprint.pprint("Adding new process")
        if extent:
            if extent[0] == '/' and extent[-4:] == '.shp' and os.path.isfile(extent):
                p = Popen(["mapcache_seed", "-c", jobdir+"/mapcacheConfig.xml", "-t", "default", "-z", zoomLevels, "-M", metatile, "-g", grid, "-d", extent], shell=False)
                p.jobid = job.id
            else:
                p = Popen(["mapcache_seed", "-c", jobdir+"/mapcacheConfig.xml", "-t", "default", "-z", zoomLevels, "-M", metatile, "-g", grid, "-e", extent], shell=False)
                p.jobid = job.id

        elif dbconfig:
           #TODO: ADD SUPPORT FOR OTHER DATABASE TYPE
           #ALSO, THIS CODE COULD PROBABLY BE PLACED IN A FUNCTION SOMEWHERE ELSE 
           if dbconfig['type'].lower() == 'postgis':
                connection_string = 'PG:dbname=' + dbconfig['name'] + ' host=' + dbconfig['host'] + ' port=' + dbconfig['port'] + ' user=' + dbconfig['user'];
                if dbconfig['password']:
                    connection_string += ' password=' + dbconfig['password'] 
                else:
                    connection_string = ''

                query_string = dbconfig['query'].rstrip(';')

           #start mapcache
           p = Popen(["mapcache_seed", "-c", jobdir+"/mapcacheConfig.xml", "-t", "default", "-z", zoomLevels, "-M", metatile, "-g", grid, "-d", connection_string, '-s', query_string], shell=False)

           p.jobid = job.id
   
        # Lock the processes list before adding data
        self.lock.acquire()
        self.processes.append(p)

        #If thread is finished, start it up
        if self.thread is None or not self.thread.isAlive():
            self.thread = None
            self.thread = self.pollProcesses(self)
            self.thread.start()
        self.lock.release()
        return
开发者ID:alexbrault,项目名称:scribeui,代码行数:84,代码来源:processManager.py


注:本文中的subprocess.Popen.jobid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。