示例#1
0
 def method_13(self, string_0, bool_0):
     if (String.IsNullOrEmpty(string_0)):
         return "<br>";
     if (not bool_0):
         return string_0;
     string_0 = String.QString2Str(string_0)
     return string_0.replace(" ", "&nbsp;");
示例#2
0
    def translate(self,
                  context,
                  sourceText,
                  disambiguation=None,
                  encoding=QCoreApplication.UnicodeUTF8,
                  n=-1):
        # da usare in una riga senza accoppiarla ad altre chiamate ad esempio (per lupdate.exe che altrimenti non le trova):
        # NON VA BENE
        #     proplist["blockScale"] = [QadMsg.translate("Dimension", "Scala frecce"), \
        #                               self.blockScale]
        # VA BENE
        #     msg = QadMsg.translate("Dimension", "Scala frecce")
        #     proplist["blockScale"] = [msg, self.blockScale]

        # contesti:
        # "QAD" per traduzioni generali
        # "Popup_menu_graph_window" per il menu popup nella finestra grafica
        # "Text_window" per la finestra testuale
        # "Command_list" per nomi di comandi
        # "Command_<nome comando in inglese>" per traduzioni di un comando specifico (es. "Command_PLINE")
        # "Snap" per i tipi di snap
        # finestre varie (es. "DSettings_Dialog", DimStyle_Dialog, ...)
        # "Dimension" per le quotature
        # "Environment variables" per i nomi delle variabili di ambiente
        # "Help" per i titoli dei capitoli del manuale che servono da section nel file html di help
        return String.QString2Str(
            QCoreApplication.translate(context, sourceText, disambiguation,
                                       encoding, n))
    def btnActivateNow_Click(self):
        licenceKey = self.getLicenceKey()
        if (String.IsNullOrEmpty(licenceKey) == False):
            objValidate = Validate()
            objValidate.secretPhase = "aerodrome$pw3s$Pa$$W0rd"  #Constants.SKGLSecretPhase;
            objValidate.Key = String.QString2Str(licenceKey).replace("-", "")

            # filePath = define.appPath + "/key.key"
            # fileStream = open(filePath, 'wb')
            # fileStream.write(licenceKey)
            # fileStream.close()
            # self.accept();

            if (objValidate.IsValid and objValidate.IsOnRightMachine):
                import _winreg as wr

                aReg = wr.ConnectRegistry(None, wr.HKEY_LOCAL_MACHINE)
                aKey = None
                try:
                    targ = r'SOFTWARE\Microsoft\Windows\FlightPlannerLicense'
                    print "*** Writing to", targ, "***"
                    try:
                        aKey = wr.OpenKey(aReg, targ, 0, wr.KEY_WRITE)
                    except:
                        aKey = wr.CreateKey(aReg, targ)
                    try:
                        try:
                            wr.SetValueEx(aKey, "License", 0, wr.REG_SZ,
                                          String.QString2Str(licenceKey))
                        except Exception:
                            print "Encountered problems writing into the Registry..."
                    except:
                        print "NO"
                    finally:
                        wr.CloseKey(aKey)
                except:
                    print "no"
                finally:
                    try:
                        wr.CloseKey(aReg)
                        self.accept()
                    except:
                        pass
            else:
                QtGui.QMessageBox.warning(self, "Warning",
                                          "Please enter a valid key.")
示例#4
0
 def getLLCornerLongitude1kk(self, inomen):
     """Get lower left Longitude for 1:1.000.000 scale
     """
     inomen = String.QString2Str(inomen)
     fuso = int(inomen[3:5])
     x = 0
     if ((fuso > 0) and (fuso <= 60)):
         x = (((fuso - 30) * 6.0) - 6.0)
     return x
示例#5
0
 def HtmlBody(self, lines, title):
     lines.AppendLine("<div>");
     if (not String.IsNullOrEmpty(title)):
         lines.AppendLine(String.Concat(["<p align=\"center\"><b>", title, "</b></p>"]));
     strArrays = Extensions.smethod_3(self.Text);
     for i in range(strArrays.count()):
         str0 = String.QString2Str(strArrays[i]);
         lines.AppendLine("{0}<br>".format(str0));
     lines.AppendLine("</div>");
 def smethod_6(string_0):
     num = 0
     string0 = string_0
     string0 = String.QString2Str(string0)
     for si in string0:
         if (si != ' '):
             return num
         num += 1
     return num
示例#7
0
 def getHemisphereMultiplier(self, inomen):
     """Check the hemisphere
     """
     inomen = String.QString2Str(inomen)
     if len(inomen) > 1:
         h = inomen[0].upper()
         if h == 'S':
             return -1
         else:
             return 1
示例#8
0
 def smethod_2(string_0):
     str0 = ""
     if isinstance(string_0, QString):
         str0 = String.QString2Str(string_0)
     else:
         str0 = string_0
     charArray = String.CharArray2Str(str0)
     flagArray = CRC.CRC32POLY
     for i in range(len(string_0)):
         CRC.smethod_6(flagArray, CRC.smethod_3(charArray[i]))
     return CRC.smethod_5(flagArray)
示例#9
0
 def getLLCornerLatitude1kk(self, inomen):
     """Get lower left Latitude for 1:1.000.000 scale
     """
     inomen = String.QString2Str(inomen)
     l = inomen[1].upper()
     y = 0.0
     operator = self.getHemisphereMultiplier(inomen)
     verticalPosition = string.uppercase.index(l)
     y = (y + 4 * verticalPosition) * operator
     if (operator < 0): y -= 4
     return y
    def acceptDlg(self):
        try:
            if (String.IsNullOrEmpty(self.txtName.Value) == False
                    and String.IsNullOrEmpty(self.txtEmail.Value) == False):
                machinCode = ""
                obj = SerialKeyConfiguration()

                # //string code = objGenerate.doKey(30);
                machinCode = str(obj.MachineCode)
                messagebody = ""
                messagebody += "Name: " + self.txtName.Value + "\n"
                messagebody += "Email: " + self.txtEmail.Value + "\n"
                messagebody += "Phone Number : " + self.txtPhoneNo.Value + "\n"
                messagebody += "Company: " + self.txtCompany.Value + "\n"
                messagebody += "Address: " + self.txtAddress.Value + "\n"
                messagebody += "Machine code: " + str(machinCode) + "\n"

                import smtplib
                from email.mime.text import MIMEText
                subject = define.MailSubject
                msg = MIMEText(String.QString2Str(messagebody))
                msg['Subject'] = define.MailSubject
                message = self.createhtmlmail(subject, None, messagebody)
                server = smtplib.SMTP_SSL(define.smtpServer + ":" +
                                          str(define.smtpPort))
                server.login(define.email, define.password)
                server.sendmail(define.FromEmail, define.ToEmail,
                                msg.as_string())
                server.quit()
                # client = new SmtpClient(SMTPSERVER);
                # client.Port = SMTPPORT;
                # client.EnableSsl = true;
                # client.Timeout = 100000;
                # client.DeliveryMethod = SmtpDeliveryMethod.Network;
                # client.UseDefaultCredentials = false;
                # client.Credentials = new NetworkCredential(
                #   SMTPEmail, SMTPPassword);
                # MailMessage msg = new MailMessage();
                # msg.To.Add(ToEmail);
                # msg.From = new MailAddress(FromEmail);
                # msg.Subject = MailSubject;
                # msg.Body = messagebody;
                # System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object s, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { return true; };
                # client.Send(msg);
                # MessageBox.Show("Successfully Sent Message.");
            else:
                QMessageBox.warning(
                    self, "Warning",
                    "Sorry! Name and email is required field.")
        except Exception as ex:
            QMessageBox.warning(self, "Warning", ex.message)
        self.accept()
示例#11
0
    def set_HexString(self, value):
        if value == "":
            return
        # value = value.replace(" ", "")
        if (self.bytes == None or len(self.bytes) != 40):
            self.bytes = bytearray(40)
        i = 0

        valueList = value.split(' ')
        while i< 40:
            if isinstance(value, QString):
                # ss = value.mid(i, 2)
                self.bytes[i] = Type.ByteFunc.d2b(int(String.QString2Str(valueList[i]), 16))
            else:
                self.bytes[i] = Type.ByteFunc.d2b(int(valueList[i], 16))
            i += 1
示例#12
0
 def getLLCorner(self, inomen):
     """Get lower left coordinates for scale determined by the given map index
     """
     inomen = String.QString2Str(inomen)
     x = self.getLLCornerLongitude1kk(inomen)
     y = self.getLLCornerLatitude1kk(inomen)
     inomenParts = inomen.upper().split('-')
     #Escala de 500.00
     for partId in range(2, len(inomenParts)):
         scaleId = partId - 1
         dx = self.getSpacingX(self.scales[scaleId])
         dy = self.getSpacingY(self.scales[scaleId])
         scaleText = inomenParts[partId]
         i, j = self.findScaleText(scaleText, partId - 1)
         x += i * dx
         y += j * dy
     return (x, y)
示例#13
0
    def smethod_4(string_0):
        symbol = None;
        flag = False;
        if isinstance(string_0, QString):
            string_0 = String.QString2Str(string_0)
        if ((string_0[len(string_0) - 1:] == 'm' or string_0[len(string_0) - 1:] == 'M') and not string_0 == "phxlmm"):
            string_0 = string_0[:len(string_0) - 1];
            flag = True;

        for current in SymbolTypeList:
            if current != string_0:
            # if (!string_0.StartsWith(string.Concat("PHX", current.ToString().ToLower()), StringComparison.InvariantCultureIgnoreCase))
            # {
                continue;
            symbol = Symbol(current, flag);
            return symbol;
        return None;
示例#14
0
    def WriteSettings(self):
        import _winreg as wr

        aReg = wr.ConnectRegistry(None, wr.HKEY_LOCAL_MACHINE)
        targ = r'SOFTWARE\Microsoft\Windows\FlightPlannerLicense'
        print "*** Writing to", targ, "***"
        try:
            aKey = wr.OpenKey(aReg, targ, 0, wr.KEY_WRITE)
        except:
            aKey = wr.CreateKey(aReg, targ)
        try:
            try:
                wr.SetValueEx(aKey, "ProjectPath", 0, wr.REG_SZ,
                              String.QString2Str(self.ProjectFolderPath))
            except Exception:
                print "Encountered problems writing into the Registry..."
        except:
            print "NO"
        finally:
            wr.CloseKey(aKey)
            wr.CloseKey(aReg)
示例#15
0
    def runAndCreateLayer(parent):
        geomDialog = QgsNewVectorLayerDialog(parent)
        if (geomDialog.exec_() == QDialog.Rejected):
            return ""

        geometrytype = geomDialog.selectedType()
        fileformat = geomDialog.selectedFileFormat()
        enc = geomDialog.selectedFileEncoding()
        crsId = geomDialog.selectedCrsId()
        print(QString("New file format will be: %1").arg(fileformat))

        attributes = dict()
        geomDialog.attributes(attributes)

        settings = QSettings()
        lastUsedDir = settings.value("/UI/lastVectorFileFilterDir",
                                     QDir.homePath()).toString()
        filterString = QgsVectorFileWriter.filterForDriver(fileformat)
        fileName = QFileDialog.getSaveFileName(parent, "Save layer as...",
                                               lastUsedDir, filterString)
        if (fileName.isNull()):
            return ""

        if (fileformat == "ESRI Shapefile"
                and not fileName.endsWith(".shp", Qt.CaseInsensitive)):
            fileName += ".shp"

        settings.setValue("/UI/lastVectorFileFilterDir",
                          QFileInfo(fileName).absolutePath())
        settings.setValue("/UI/encoding", enc)

        #try to create the new layer with OGRProvider instead of QgsVectorFileWriter
        pReg = QgsProviderRegistry.instance()
        ogrlib = pReg.library("ogr")
        # load the data provider
        myLib = QLibrary(ogrlib)
        loaded = myLib.load()

        constructionLineLayer = None
        mapUnits = define._canvas.mapUnits()
        layerName = String.QString2Str(fileName).split("\\")[-1]
        path = "memory"
        selectedCrs = geomDialog.selectedCrs()
        if geometrytype == QGis.Line:
            # if mapUnits == QGis.Meters:
            constructionLineLayer = QgsVectorLayer(
                "linestring?crs=%s" % selectedCrs.authid(), layerName, path)
            # else:
            #     constructionLineLayer = QgsVectorLayer("linestring?crs=%s"%define._latLonCrs.authid (), layerName, path)

        elif geometrytype == QGis.Polygon:
            # if mapUnits == QGis.Meters:
            constructionLineLayer = QgsVectorLayer(
                "polygon?crs=%s" % selectedCrs.authid(), layerName, path)
            # else:
            #     constructionLineLayer = QgsVectorLayer("polygon?crs=%s"%define._latLonCrs.authid (), layerName, path)

        elif geometrytype == QGis.Point:
            # if mapUnits == QGis.Meters:
            constructionLineLayer = QgsVectorLayer(
                "Point?crs=%s" % selectedCrs.authid(), layerName, path)
            # else:
            #     constructionLineLayer = QgsVectorLayer("Point?crs=%s"%define._latLonCrs.authid (), layerName, path)
        fieldList = []
        for key in attributes.iterkeys():
            fieldList.append(QgsField(key, attributes[key][0]))
        constructionLineLayer.startEditing()
        constructionLineLayer.dataProvider().addAttributes(fieldList)
        constructionLineLayer.commitChanges()

        er = QgsVectorFileWriter.writeAsVectorFormat(
            constructionLineLayer, fileName, "utf-8",
            constructionLineLayer.crs())
        constructionLineLayer = QgsVectorLayer(fileName, layerName, "ogr")

        QgisHelper.appendToCanvas(define._canvas, [constructionLineLayer],
                                  "NewLayers")

        # if ( loaded ):
        #     print( "ogr provider loaded" )
        #
        #     typedef bool ( *createEmptyDataSourceProc )( const QString&, const QString&, const QString&, QGis::WkbType,
        #     const QList< QPair<QString, QString> >&, const QgsCoordinateReferenceSystem * )
        #     createEmptyDataSourceProc createEmptyDataSource = ( createEmptyDataSourceProc ) cast_to_fptr( myLib.resolve( "createEmptyDataSource" ) )
        #     if ( createEmptyDataSource )
        #     {
        #         if ( geometrytype not = QGis::WKBUnknown )
        #         {
        #             QgsCoordinateReferenceSystem srs = QgsCRSCache::instance().crsBySrsId( crsId )
        #             if ( not createEmptyDataSource( fileName, fileformat, enc, geometrytype, attributes, &srs ) )
        #             {
        #                 return QString::null
        #             }
        #         }
        #         else
        #         {
        #             QgsDebugMsg( "geometry type not recognised" )
        #             return QString::null
        #         }
        #     }
        #     else
        #     {
        #         QgsDebugMsg( "Resolving newEmptyDataSource(...) failed" )
        #         return QString::null
        #     }
        # }
        #
        # if ( pEnc )
        # *pEnc = enc

        return fileName
示例#16
0
 def get_Title(self):
     fileInfo = QFileInfo(self.fileName)
     return String.QString2Str(fileInfo.fileName())
 def smethod_4(string_0):
     string_0 = String.QString2Str(string_0)
     return string_0.split('\t')
示例#18
0
def main(argv):

    import _winreg as windowsregistry
    licensekey = None
    localmachinekeyhandle = windowsregistry.ConnectRegistry(None, windowsregistry.HKEY_LOCAL_MACHINE)
    keyhandle = None

    try:
        keyargument = r'SOFTWARE\Microsoft\Windows\FlightPlannerLicense'
        print "*** Reading from", keyargument, "***"
        keyhandle = windowsregistry.OpenKey(localmachinekeyhandle, keyargument)
        try:
            n, v, t = windowsregistry.EnumValue(keyhandle, 0)
            if n == "License":
                licensekey = v
                print licensekey
        except:
            print "no license"
        finally:
            try:
                windowsregistry.CloseKey(keyhandle)
            except:
                pass
    except:
        print "no License trag"
    finally:
        try:
            windowsregistry.CloseKey(localmachinekeyhandle)
        except:
            pass

        # create QGis application
        app = QgsApplication(argv, True)

        QCoreApplication.setOrganizationName("IRSG")
        QCoreApplication.setOrganizationDomain("*****@*****.**")
        QCoreApplication.setApplicationName("FlightPlanner")

        # Initialize qgis libraries
        QgsApplication.setPrefixPath(".", True)
        QgsApplication.initQgis()

        licenceflag = False

        if licensekey is not None:

            print "Compare Start"
            objvalidate = Validate()
            print "aerodrome$pw3s$Pa$$W0rd"
            objvalidate.secretPhase = "aerodrome$pw3s$Pa$$W0rd"
            objvalidate.Key = String.QString2Str(QString(licensekey)).replace("-", "")
            print objvalidate.Key

            try:
                if objvalidate.IsValid and objvalidate.IsOnRightMachine and objvalidate.SetTime >= objvalidate.DaysLeft:  # and objValidate.IsExpired == False ):
                    licenceflag = True
            except:
                pass

        define._appWidth = QApplication.desktop().screenGeometry().width()
        define._appHeight = QApplication.desktop().screenGeometry().height()

        window = MyWnd()
        window.setWindowState(Qt.WindowMaximized)
        window.show()
        retval = app.exec_()

        AirCraftOperation.ApplicationSetting.WriteSettings()

        QgsApplication.exitQgis()
        sys.exit(retval)
def main(argv):

    import _winreg as wr
    licenseKey = None
    aReg = wr.ConnectRegistry(None, wr.HKEY_LOCAL_MACHINE)
    aKey = None
    try:
        targ = r'SOFTWARE\Microsoft\Windows\FlightPlannerLicense'
        print "*** Reading from", targ, "***"
        aKey = wr.OpenKey(aReg, targ)
        try:
            n, v, t = wr.EnumValue(aKey, 0)
            if n == "License":
                licenseKey = v
                print licenseKey
        except:
            print "no license"
        finally:
            try:
                wr.CloseKey(aKey)
            except:
                pass
    except:
        print "no License trag"
    finally:
        try:
            wr.CloseKey(aReg)
        except:
            pass
        app = QApplication(argv)
        QgsApplication.setPrefixPath(".", True)
        a = QgsApplication.initQgis()

        # f = file("D:/ccc.txt", "w")
        # ss = ["sfdffdsf", "233424324", "sdfsdfs"]
        # f.write("start")
        # f.writelines(ss)
        # f.close()

        print "File print End"
        licenceFlag = False
        if licenseKey != None:

            print "Compare Start"
            objValidate = Validate()
            print "aerodrome$pw3s$Pa$$W0rd"
            objValidate.secretPhase = "aerodrome$pw3s$Pa$$W0rd"
            # GlobalSettings objSetting = GlobalSettings.Load(Constants.globaleSettingsPath);
            objValidate.Key = String.QString2Str(QString(licenseKey)).replace(
                "-", "")
            print objValidate.Key
            # objValidate.Key = "IVAII-UTDIE-HGIEG-WMVOG"
            try:
                if (objValidate.IsValid and objValidate.IsOnRightMachine
                        and objValidate.SetTime >= objValidate.DaysLeft
                    ):  # and objValidate.IsExpired == False ):
                    licenceFlag = True
            except:
                pass
        print licenceFlag
        # if not licenceFlag:
        #     dlgLicensing = DlgLicensing()
        #     licenceFlag = dlgLicensing.exec_()
        # if licenceFlag:
        #     print "Start  MyWnd"
        define._appWidth = QApplication.desktop().screenGeometry().width()
        define._appHeight = QApplication.desktop().screenGeometry().height()

        window = MyWnd()
        window.setWindowState(Qt.WindowMaximized)
        window.show()
        retval = app.exec_()

        AirCraftOperation.g_AppSetting.WriteSettings()
        if retval:
            pass
        QgsApplication.exitQgis()
        sys.exit(retval)