Example #1
0
    def getFilesToProcess(self):
        db = None
        cur = None
        filesList = []
        try:
            db = pymysql.connect(self.DATABASEIP, self.DB_USER,
                                 self.DB_PASSWORD, self.DATABASE)
            cur = db.cursor()
            processed = "N"
            args = (processed)
            sql = 'Select FileName,ProjectName,ProjectUserID,Processed,UploadDate,UploadPath,Lang , FileID from project_files where Processed = %s'
            cur.execute(sql, args)

            for row in cur.fetchall():
                ProjectFile_ = ProjectFile(row[0], row[1], row[2], row[3],
                                           row[4], row[5], row[6])
                ProjectFile_.setFileID(row[7])
                filesList.append(ProjectFile_)
                del ProjectFile_

        except Exception as error:
            raise DBError('Can not insert File  Data into DB ' + str(error))
            print("In DB Handler storing file Data", error)
        finally:
            if (db != None):
                db.close()
        return filesList
Example #2
0
    def setWorkDir(cls,parent):
        parent.workDir=QFileDialog.getExistingDirectory()
        if len(parent.workDir)>0:
            parent.setExtraFileName()

            #保存工程文件
            pj=ProjectFile(parent.projectFile)     
            pj.createProject() 

        else:
            parent.workDir=None
Example #3
0
    def importFullImages(cls,parent):
        if parent.workDir is None:
            return

        files,ext = QFileDialog.getOpenFileNames(parent,  
                                    "导入全图",  
                                    './',  
                                    "Image Files (*.jpg *tif)")  
        if len(files)>0:
            parent.centerUi.fullViewer.insertFiles(files) 
            #保存工程文件
            pj=ProjectFile(parent.projectFile)     
            pj.setFullImages(files) 
Example #4
0
    def openWork(cls,parent):
        file, ext = QFileDialog.getOpenFileName(parent,  
                                    "文件选择",  
                                    './',  
                                    "PRO Files (*.pro)")          
        if len(file)>0:
            parent.projectFile=file
            parent.workDir=os.path.split(file)[0]
            parent.setExtraFileName()

            #保存工程文件
            pj=ProjectFile(parent.projectFile)     
            (files1,files2)=pj.getImages() 
        
            parent.centerUi.fileViewer.insertFiles(files1)#显示文件名列表
            parent.centerUi.fullViewer.insertFiles(files2)#显示文件名列表

            controlPointName=parent.workDir+'/'+Attribute.controlPointName
            parent.centerUi.pointsViewer.setPointsFile(controlPointName)
Example #5
0
    def importImages(cls,parent):
        if parent.workDir is None:
            return

        files,ext = QFileDialog.getOpenFileNames(parent,  
                                    "导入待拼接图像",  
                                    './',  
                                    "Image Files (*.jpg *tif)")  
        if len(files)>0:
            parent.centerUi.fileViewer.insertFiles(files)
            #保存工程文件
            pj=ProjectFile(parent.projectFile)     
            pj.setNoramlImages(files)     

            latlonName=parent.workDir+'/'+Attribute.imageLocationName

            #从图片中获取坐标信息        
            command=[]
            command.append(parent.programPath+'/modules/exifcoords.exe')
            command.append(parent.projectFile)
            command.append(latlonName)
            
            subprocess.Popen(command, startupinfo=Attribute.startupinfo, shell=False, close_fds=True)
Example #6
0
	def __init__(self, bls_path, bll_path):
		self.bls     = ProjectFile(bls_path)
		self.bll     = ProjectFile(bll_path)
		self.uses    = []
		self.dep     = [] # список файлов ссылающихся на этот модуль
		self.compile = True # нуждается ли в компилировании
Example #7
0
class BlsObj(object):
	def __init__(self, bls_path, bll_path):
		self.bls     = ProjectFile(bls_path)
		self.bll     = ProjectFile(bll_path)
		self.uses    = []
		self.dep     = [] # список файлов ссылающихся на этот модуль
		self.compile = True # нуждается ли в компилировании

	def update_bls(self):
		self.uses    = []
		self.dep     = []

		if self.bls.is_exists():
			data = self.bls.get_data()
			self.bls.update_md5(data)
			self.uses = utils.parse_bls(data, 'uses')

	def update_bll(self):
		if self.bll.is_exists():
			data = self.bll.get_data()
			self.bll.update_md5(data)

	def add_dep(self, name):
		self.dep.append(name)

	def gen_xml_dict(self, bls_dict):
		if self.compile:
			return
		bls_dict[self.bls.get_name()] = {"bls_md5" : self.bls.get_md5(), "bll_md5" : self.bll.get_md5()}

	def load_xml_dict(self, bls_md5, bll_md5):
		"""На этом этапе идет сравнение данных из xml и реальных данных,
			по результатам делается вывод нужно ли компилировать файл
		"""
		self.compile = True
		debug = False

		# в прошлый раз файл не был скомпилирован
		if bls_md5 == '' or bll_md5 == '':
			if debug:
				print self.get_bls_path() + ': not compiled'
			return
		# bll удалена или не была скомпилирована
		if not self.bll.is_exists():
			if debug:
				print self.get_bls_path() + ': bll not exists'
			return
		# bls изменилась
		if bls_md5 != self.bls.get_md5():
			if debug:
				print self.get_bls_path() + ': bls change'
			return
		# bll изменилась
		self.update_bll()
		if bll_md5 != self.bll.get_md5():
			if debug:
				print self.get_bls_path() + ': bll change'
			return

		self.compile = False

	def remove_bll(self):
		if self.bll.is_exists():
			os.remove(self.bll.get_path())

	def need_compile(self, arr):
		self.compile = True
		for it in self.dep:
			arr[it].need_compile(arr)

	def on_compiled(self):
		self.compile = False
		self.update_bll()

	def get_name(self):
		return self.bls.get_name()

	def is_need_compile(self):
		return self.compile

	def get_bls_path(self):
		return self.bls.get_path()
Example #8
0
def upload_file_s():
    try:
        print("Here in uploader new")
        if request.method == 'POST':
            file = request.files['file']
            pname = request.form['pname']
            lang = request.form['lang']

            if file.filename == '':
                print("file name is empty")
                return redirect(
                    url_for('addfiles.html', message='No selected file'))
            if file and allowed_file(file.filename):
                filename = secure_filename(file.filename)
                file.filename = filename
                print("file", file.filename)

                file.save(
                    os.path.join(app.config['UPLOAD_PATH_PDF'], file.filename))
                processed = "N"
                datetime_now = datetime.datetime.now()
                formatted_date = datetime_now.strftime('%Y-%m-%d')

                projectFile_ = ProjectFile(file.filename, pname,
                                           session['user'], processed,
                                           formatted_date,
                                           app.config['UPLOAD_PATH_PDF'], lang)

                dbHandler_ = DBHandler(app.config["DATABASEIP"],
                                       app.config["DB_USER"],
                                       app.config["DB_PASSWORD"],
                                       app.config["DATABASE"])
                dbHandler_.insertFiles(projectFile_)
                if (projectFile_.lang == "eng"):
                    try:
                        FileProcessor_ = FileProcessor()
                        FileProcessor_.process(projectFile_)
                        dbHandler_.updateFileStatus(projectFile_.FileName, "Y")
                    except Exception as e:
                        dbHandler_.updateFileStatus(projectFile_.FileName, "F")
                        return render_template(
                            'addfiles.html',
                            email=session['user'],
                            projectList=session['projectList'],
                            message="File processing is failed due to error:" +
                            str(e))

                return render_template(
                    'addfiles.html',
                    email=session['user'],
                    projectList=session['projectList'],
                    message=
                    "File is successfully uploaded. File will be processed in a while"
                )

    except DBError as e:
        return render_template('addfiles.html',
                               projectList=session['projectList'],
                               email=session['user'],
                               message='Exception in file processing' + str(e))

    except Exception as e:
        return render_template('addfiles.html',
                               projectList=session['projectList'],
                               email=session['user'],
                               message='Exception in file processing' + str(e))