def _testParsePropertiesOutput(self, stream):
   properties = Properties()
   properties.setProperty('Key00', 'Value00')
   properties.setProperty('Key01', 'Value01')
   properties.setProperty('Key02', 'Value02')
   properties.setProperty('Key03', 'Value03')
   properties.setProperty('Key04', 'Value04')
   properties.setProperty('Key05', 'Value05a, Value05b, Value05c')
   properties.setProperty('Key06', 'Value06a, Value06b, Value06c',)
   properties.setProperty('Key07', 'Value07b')
   properties.setProperty('Key08',
       'Value08a, Value08b, Value08c, Value08d, Value08e, Value08f')
   properties.setProperty('Key09',
       'Value09a, Value09b, Value09c, Value09d, Value09e, Value09f')
   properties.setProperty('Key10', 'Value10')
   properties.setProperty('Key11', '')
   properties.setProperty('Key12', 'Value12a, Value12b, Value12c')
   properties.setProperty('Key13', 'Value13 With Spaces')
   properties.setProperty('Key14', 'Value14 With Spaces')
   properties.setProperty('Key15', 'Value15 With Spaces')
   properties.setProperty('Key16 With Spaces', 'Value16')
   properties.setProperty('Key17 With Spaces', 'Value17')
   properties.setProperty('Key18', 'Value18 # Not a comment.')
   properties.setProperty('Key19', 'Value19 ! Not a comment.')
   properties.setProperty('Key20=WithEquals', 'Value20')
   properties.setProperty('Key21:WithColon', 'Value21')
   properties.setProperty('Key22', 'Value22')
   properties.store(stream)
Esempio n. 2
0
    def gather_dependencies(self):
        log.info('gathering dependencies...')
        self.npm(['shrinkwrap'])
        shrinkwrapFile = join(self.module_dir, 'npm-shrinkwrap.json')
        if is_existing_file(shrinkwrapFile):
            move(shrinkwrapFile, self.shrinkwrap)

        # clean shrinkwrap file see spec on https://wiki.wdf.sap.corp/wiki/display/xs2/Filtering+SAP-internal+metadata+before+release
        cleanedShrinwrap = {}
        with open(self.shrinkwrap, 'r') as f:
            cleanedShrinwrap = json.load(f)

        keystoremove = []
        self._clean_shrinkwrap(cleanedShrinwrap,
                               listofkeytoremove=keystoremove)
        for keys in keystoremove:
            shrinkwrappart = cleanedShrinwrap
            for key in keys[:-1]:
                shrinkwrappart = shrinkwrappart[key]
            shrinkwrappart.pop(keys[-1], None)

        with open(self.shrinkwrap, 'w') as jsonfile:
            json.dump(cleanedShrinwrap, jsonfile, indent=2)

        dep = self.module_dir
        p = Properties()
        for (m, v) in self.list_deps(join(dep), ''):
            p.setProperty(m, v)
        with open(self.deps, 'w') as f:
            p.store(f)
        copyfile(self.deps, join(dep, 'dependencies'))
Esempio n. 3
0
def change_dbms_config(db):
    from pyjavaproperties import Properties
    p = Properties()
    p.load(open('config/database.properties'))
    print p['dbms']
    print db
    p['dbms'] = db
    p.store(open('config/database.properties', 'w'))
Esempio n. 4
0
    def write(keydict, savedir):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        loadfile = os.path.join(savedir, JitsiProperties.propertiesfile)
        savefile = loadfile
        if not os.path.exists(loadfile) and os.path.exists(JitsiProperties.path):
            print 'Adium WARNING: "' + loadfile + '" does not exist! Reading from:'
            loadfile = os.path.join(JitsiProperties.path, JitsiProperties.propertiesfile)
            print '\t"' + loadfile + '"'

        propkey_base = 'net.java.sip.communicator.plugin.otr.'
        p = Properties()
        p.load(open(loadfile))
        for name, key in keydict.iteritems():
            if 'verification' in key and key['verification'] != '':
                verifiedkey = (propkey_base + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                               + '_publicKey_verified')
                p[verifiedkey] = 'true'
            if 'y' in key:
                pubkey = (propkey_base + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                          + '_publicKey')
                p.setProperty(pubkey, util.ExportDsaX509(key))
            if 'x' in key:
                suffix2 = ''
                if '@' in key['name']:
                    suffix = re.sub('[^a-zA-Z0-9_]', '_', key['name'].split('@')[1])
                    if 'facebook' in key['name'].split('@')[1]:
                        protocolAcc = 'Facebook_'
                    elif 'gmail' in key['name'].split('@')[1]:
                        protocolAcc = 'Google_Talk_'
                        suffix2 = 'talk_google_com'
                    else:
                        protocolAcc = 'Jabber_'
                elif '@' not in key['name']:
                    if 'icq' in key['protocol']:
                        protocolAcc = 'ICQ_'
                        suffix = 'icq_com'
                    elif 'yahoo' in key['protocol']:
                        protocolAcc = 'Yahoo__'
                        suffix = 'yahoo_com'
                # Writing
                pubkey = (propkey_base + protocolAcc + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                          + '_' + suffix + '_publicKey')
                p.setProperty(pubkey, util.ExportDsaX509(key))
                privkey = (propkey_base + protocolAcc + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                           + '_' + suffix + '_privateKey')
                p.setProperty(privkey, util.ExportDsaPkcs8(key))
		   
                if suffix2 != '':
                    pubkey = (propkey_base + protocolAcc + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                              + '_' + suffix2 + '_publicKey')
                    p.setProperty(pubkey, util.ExportDsaX509(key))
                    privkey = (propkey_base + protocolAcc + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                               + '_' + suffix2 + '_privateKey')
                    p.setProperty(privkey, util.ExportDsaPkcs8(key))	
		   		
        p.store(open(savefile, 'w'))
Esempio n. 5
0
def update_properties_file(properties_file, new_properties):
    p = Properties()
    logging.debug('Opening file %s', properties_file)
    p.load(open(properties_file))
    for name, value in new_properties:
        logging.info('Setting new value of %s to %s', name, value)
        p[name] = value
    logging.debug('Saving file %s with new values', properties_file)
    p.store(open(properties_file, 'w'))
Esempio n. 6
0
 def write_to_report():
     prop = Properties()
     out = open(globals.ALLURE_RESULTS + "environment.properties", mode='w')
     prop.setProperty("Browser", ReadConfig.browser())
     prop.setProperty("URL", ReadConfig.get_url())
     prop.setProperty("Python", str(sys.version))
     window_version = str(sys.getwindowsversion())
     prop.setProperty("Platform", window_version.title())
     prop.store(out)
Esempio n. 7
0
def write_version_properties(build_cfg):
    p = Properties()
    log.info('version is ' + build_cfg.version())
    log.info('scm_url is ' + str(build_cfg.scm_snapshot_url()))
    p.setProperty('release_version', build_cfg.version())
    p.setProperty('scm_url', str(build_cfg.scm_snapshot_url()))

    #     pairs = [('release_version', build_cfg.version()),
    #              ('scm_url', build_cfg.scm_snapshot_url())]
    #     contents = '\n'.join([key + '=' + str(value) for (key, value) in pairs])
    with open(build_cfg.version_properties_file(), 'w') as f:
        p.store(f)
Esempio n. 8
0
    def __setattr__(self, name, value):
        # For each property assigned to the instance object, we write it to the
        #file, If it doesn't exist we add it.
        app_properties = Properties()
        with open(APP_PROP_FILE, "r") as app_property_file:
            app_properties.load(app_property_file)
            current_properties = app_properties.propertyNames()

        if name not in current_properties or value != app_properties.get(name):
            with open(APP_PROP_FILE, "w") as app_property_file:
                app_properties[name] = value
                app_properties.store(app_property_file)

        super(MyAppProperties, self).__setattr__(name, value)
Esempio n. 9
0
def createResult(path):
    all_dir=getDirList(path)

    varss=['project.dir','outputFile']
    vars2=['outputFile','project.dir']
    for x in all_dir:
        print x
        p = Properties()
        p.load(open('rouge.properties'))

        for name, value in [('project.dir', x), ('outputFile', str(x+'_results.csv'))]:
            p[name] = value
            
        p.store(open('rouge.properties', 'w'))
        
        #time.sleep(30)
        runJar(path)
Esempio n. 10
0
    def write(keydict, savedir):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        loadfile = os.path.join(savedir, JitsiProperties.propertiesfile)
        savefile = loadfile
        if not os.path.exists(loadfile) and os.path.exists(JitsiProperties.path):
            print 'Adium WARNING: "' + loadfile + '" does not exist! Reading from:'
            loadfile = os.path.join(JitsiProperties.path, JitsiProperties.propertiesfile)
            print '\t"' + loadfile + '"'

        propkey_base = "net.java.sip.communicator.plugin.otr."
        p = Properties()
        p.load(open(loadfile))
        for name, key in keydict.iteritems():
            if "verification" in key and key["verification"] != "":
                verifiedkey = propkey_base + re.sub("[^a-zA-Z0-9_]", "_", key["name"]) + "_publicKey_verified"
                p[verifiedkey] = "true"
            if "y" in key:
                pubkey = propkey_base + re.sub("[^a-zA-Z0-9_]", "_", key["name"]) + "_publicKey"
                p.setProperty(pubkey, util.ExportDsaX509(key))
            if "x" in key and "@" in key["name"]:
                pubkey = (
                    propkey_base
                    + "Jabber_"
                    + re.sub("[^a-zA-Z0-9_]", "_", key["name"])
                    + "_"
                    + re.sub("[^a-zA-Z0-9_]", "_", key["name"].split("@")[1])
                    + "_publicKey"
                )
                p.setProperty(pubkey, util.ExportDsaX509(key))
                privkey = (
                    propkey_base
                    + "Jabber_"
                    + re.sub("[^a-zA-Z0-9_]", "_", key["name"])
                    + "_"
                    + re.sub("[^a-zA-Z0-9_]", "_", key["name"].split("@")[1])
                    + "_privateKey"
                )
                p.setProperty(privkey, util.ExportDsaPkcs8(key))
        p.store(open(savefile, "w"))
Esempio n. 11
0
File: jitsi.py Progetto: duy/keysync
    def write(keydict, savedir):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        loadfile = os.path.join(savedir, JitsiProperties.propertiesfile)
        savefile = loadfile
        if not os.path.exists(loadfile) and os.path.exists(
                JitsiProperties.path):
            print 'Adium WARNING: "' + loadfile + '" does not exist! Reading from:'
            loadfile = os.path.join(JitsiProperties.path,
                                    JitsiProperties.propertiesfile)
            print '\t"' + loadfile + '"'

        propkey_base = 'net.java.sip.communicator.plugin.otr.'
        p = Properties()
        p.load(open(loadfile))
        for name, key in keydict.iteritems():
            if 'verification' in key and key['verification'] != '':
                verifiedkey = (propkey_base +
                               re.sub('[^a-zA-Z0-9_]', '_', key['name']) +
                               '_publicKey_verified')
                p[verifiedkey] = 'true'
            if 'y' in key:
                pubkey = (propkey_base +
                          re.sub('[^a-zA-Z0-9_]', '_', key['name']) +
                          '_publicKey')
                p.setProperty(pubkey, util.ExportDsaX509(key))
            if 'x' in key and '@' in key['name']:
                pubkey = (
                    propkey_base + 'Jabber_' +
                    re.sub('[^a-zA-Z0-9_]', '_', key['name']) + '_' +
                    re.sub('[^a-zA-Z0-9_]', '_', key['name'].split('@')[1]) +
                    '_publicKey')
                p.setProperty(pubkey, util.ExportDsaX509(key))
                privkey = (
                    propkey_base + 'Jabber_' +
                    re.sub('[^a-zA-Z0-9_]', '_', key['name']) + '_' +
                    re.sub('[^a-zA-Z0-9_]', '_', key['name'].split('@')[1]) +
                    '_privateKey')
                p.setProperty(privkey, util.ExportDsaPkcs8(key))
        p.store(open(savefile, 'w'))
Esempio n. 12
0
 def testParsePropertiesInput(self):
     properties = Properties()
     properties.load(open(self.properties_file))
     self.assertEqual(25, len(properties.items()))
     self.assertEqual('Value00', properties['Key00'])
     self.assertEqual('Value01', properties['Key01'])
     self.assertEqual('Value02', properties['Key02'])
     self.assertEqual('Value03', properties['Key03'])
     self.assertEqual('Value04', properties['Key04'])
     self.assertEqual('Value05a, Value05b, Value05c', properties['Key05'])
     self.assertEqual('Value06a, Value06b, Value06c', properties['Key06'])
     self.assertEqual('Value07b', properties['Key07'])
     self.assertEqual(
         'Value08a, Value08b, Value08c, Value08d, Value08e, Value08f',
         properties['Key08'])
     self.assertEqual(
         'Value09a, Value09b, Value09c, Value09d, Value09e, Value09f',
         properties['Key09'])
     self.assertEqual('Value10', properties['Key10'])
     self.assertEqual('', properties['Key11'])
     self.assertEqual('Value12a, Value12b, Value12c', properties['Key12'])
     self.assertEqual('Value13 With Spaces', properties['Key13'])
     self.assertEqual('Value14 With Spaces', properties['Key14'])
     self.assertEqual('Value15 With Spaces', properties['Key15'])
     self.assertEqual('Value16', properties['Key16 With Spaces'])
     self.assertEqual('Value17', properties['Key17 With Spaces'])
     self.assertEqual('Value18 # Not a comment.', properties['Key18'])
     self.assertEqual('Value19 ! Not a comment.', properties['Key19'])
     # Single referenced property
     self.assertEqual('Value19 ! Not a comment.Value20',
                      properties['Key20'])
     self.assertEqual('Value21', properties['Key21=WithEquals'])
     self.assertEqual('Value22', properties['Key22:WithColon'])
     self.assertEqual('Value23', properties['Key23'])
     # Multiple referenced properties with separator
     self.assertEqual(
         'Value18 # Not a comment.-separator-Value19 ! Not a comment.',
         properties['Key24'])
     properties.store(open('saved.properties', 'w'))
Esempio n. 13
0
    def write(keydict, savedir):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        loadfile = os.path.join(savedir, JitsiProperties.propertiesfile)
        savefile = loadfile
        if not os.path.exists(loadfile) and os.path.exists(JitsiProperties.path):
            print('Jitsi NOTICE: "' + loadfile + '" does not exist! Reading from:')
            loadfile = os.path.join(JitsiProperties.path, JitsiProperties.propertiesfile)
            print('\t"' + loadfile + '"')

        propkey_base = "net.java.sip.communicator.plugin.otr."
        p = Properties()
        p.load(open(loadfile))
        for name, key in keydict.items():
            if "verification" in key and key["verification"] != "":
                verifiedkey = propkey_base + re.sub("[^a-zA-Z0-9_]", "_", key["name"]) + "_publicKey_verified"
                p[verifiedkey] = "true"
            if "y" in key:
                pubkey = propkey_base + re.sub("[^a-zA-Z0-9_]", "_", key["name"]) + "_publicKey"
                p.setProperty(pubkey, otrapps.util.ExportDsaX509(key))
            if "x" in key:
                protocol_id = "UNKNOWN_"
                domain_id = "unknown"
                servername = None
                if "@" in key["name"]:
                    domainname = key["name"].split("@")[1]
                    domain_id = re.sub("[^a-zA-Z0-9_]", "_", domainname)
                    if domainname == "chat.facebook.com":
                        protocol_id = "Facebook_"
                    elif domainname == "gmail.com" or domainname == "google.com" or domainname == "googlemail.com":
                        protocol_id = "Google_Talk_"
                        servername = "talk_google_com"
                    else:
                        protocol_id = "Jabber_"
                else:
                    if key["protocol"] == "prpl-icq":
                        protocol_id = "ICQ_"
                        domain_id = "icq_com"
                    elif key["protocol"] == "prpl-yahoo":
                        protocol_id = "Yahoo__"
                        domain_id = "yahoo_com"
                # Writing
                pubkey = (
                    propkey_base
                    + protocol_id
                    + re.sub("[^a-zA-Z0-9_]", "_", key["name"])
                    + "_"
                    + domain_id
                    + "_publicKey"
                )
                p.setProperty(pubkey, otrapps.util.ExportDsaX509(key))
                privkey = (
                    propkey_base
                    + protocol_id
                    + re.sub("[^a-zA-Z0-9_]", "_", key["name"])
                    + "_"
                    + domain_id
                    + "_privateKey"
                )
                p.setProperty(privkey, otrapps.util.ExportDsaPkcs8(key))

                if servername:
                    pubkey = (
                        propkey_base
                        + protocol_id
                        + re.sub("[^a-zA-Z0-9_]", "_", key["name"])
                        + "_"
                        + servername
                        + "_publicKey"
                    )
                    p.setProperty(pubkey, otrapps.util.ExportDsaX509(key))
                    privkey = (
                        propkey_base
                        + protocol_id
                        + re.sub("[^a-zA-Z0-9_]", "_", key["name"])
                        + "_"
                        + servername
                        + "_privateKey"
                    )
                    p.setProperty(privkey, otrapps.util.ExportDsaPkcs8(key))

        p.store(open(savefile, "w"))
Esempio n. 14
0
def generate_property_file():
	p = Properties()
	p['DATE'] = datetime.now().strftime("%Y-%m-%d")
	p.store(open('k.properties','w'))
Esempio n. 15
0
    p = Properties()
    p.load(open(runtime_filepath))
    print "****Properties before****"
    p.list()
    #Add/replace environment variables that begin with v_
    for key, value in [(key[2:], os.environ[key]) for key in os.environ
                       if key.startswith("v_")]:
        print "Adding key %s: %s" % (key, value)
        p[key] = value
    #Replace mydomain in any values
    newdomain = sys.argv[2]
    for key, value in [(key, value) for (key, value) in p.iteritems()
                       if "mydomain.edu" in value]:
        new_value = value.replace("mydomain.edu", newdomain)
        print "Changing key %s from %s to %s" % (key, value, new_value)
        p[key] = new_value
    #Only set email keys if env var present.
    if os.environ.get('VIVO_EMAIL', False) != "true":
        print "Removing email settings."
        p['email.smtpHost'] = ""
        p['email.replyTo'] = ""
    #Set DB values based on docker-provided environment variables
    p['VitroConnection.DataSource.url'] = "jdbc:mysql://db/%s" % os.getenv(
        'DB_ENV_MYSQL_DATABASE')
    p['VitroConnection.DataSource.username'] = os.getenv('DB_ENV_MYSQL_USER')
    p['VitroConnection.DataSource.password'] = os.getenv(
        'DB_ENV_MYSQL_PASSWORD')
    print "****Properties after****"
    p.list()
    p.store(open(runtime_filepath, 'w'))
Esempio n. 16
0
def changePropertie(name, new_value):
    p = Properties()
    p.load(open(property_file_name, 'r'))
    #p.list()
    p[name] = new_value
    p.store(open(property_file_name, 'w'))
Esempio n. 17
0
    def write(keydict, savedir):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        loadfile = os.path.join(savedir, JitsiProperties.propertiesfile)
        savefile = loadfile
        if not os.path.exists(loadfile) and os.path.exists(
                JitsiProperties.path):
            print('Jitsi NOTICE: "' + loadfile +
                  '" does not exist! Reading from:')
            loadfile = os.path.join(JitsiProperties.path,
                                    JitsiProperties.propertiesfile)
            print('\t"' + loadfile + '"')

        propkey_base = 'net.java.sip.communicator.plugin.otr.'
        p = Properties()
        p.load(open(loadfile))
        for name, key in keydict.items():
            if 'verification' in key and key['verification'] != '':
                verifiedkey = (propkey_base +
                               re.sub('[^a-zA-Z0-9_]', '_', key['name']) +
                               '_publicKey_verified')
                p[verifiedkey] = 'true'
            if 'y' in key:
                pubkey = (propkey_base +
                          re.sub('[^a-zA-Z0-9_]', '_', key['name']) +
                          '_publicKey')
                p.setProperty(pubkey, otrapps.util.ExportDsaX509(key))
            if 'x' in key:
                protocol_id = 'UNKNOWN_'
                domain_id = 'unknown'
                servername = None
                if '@' in key['name']:
                    domainname = key['name'].split('@')[1]
                    domain_id = re.sub('[^a-zA-Z0-9_]', '_', domainname)
                    if domainname == 'chat.facebook.com':
                        protocol_id = 'Facebook_'
                    elif domainname == 'gmail.com' \
                            or domainname == 'google.com' \
                            or domainname == 'googlemail.com':
                        protocol_id = 'Google_Talk_'
                        servername = 'talk_google_com'
                    else:
                        protocol_id = 'Jabber_'
                else:
                    if key['protocol'] == 'prpl-icq':
                        protocol_id = 'ICQ_'
                        domain_id = 'icq_com'
                    elif key['protocol'] == 'prpl-yahoo':
                        protocol_id = 'Yahoo__'
                        domain_id = 'yahoo_com'
                # Writing
                pubkey = (propkey_base + protocol_id +
                          re.sub('[^a-zA-Z0-9_]', '_', key['name']) + '_' +
                          domain_id + '_publicKey')
                p.setProperty(pubkey, otrapps.util.ExportDsaX509(key))
                privkey = (propkey_base + protocol_id +
                           re.sub('[^a-zA-Z0-9_]', '_', key['name']) + '_' +
                           domain_id + '_privateKey')
                p.setProperty(privkey, otrapps.util.ExportDsaPkcs8(key))

                if servername:
                    pubkey = (propkey_base + protocol_id +
                              re.sub('[^a-zA-Z0-9_]', '_', key['name']) + '_' +
                              servername + '_publicKey')
                    p.setProperty(pubkey, otrapps.util.ExportDsaX509(key))
                    privkey = (propkey_base + protocol_id +
                               re.sub('[^a-zA-Z0-9_]', '_', key['name']) +
                               '_' + servername + '_privateKey')
                    p.setProperty(privkey, otrapps.util.ExportDsaPkcs8(key))

        p.store(open(savefile, 'w'))
import sys
import os

if __name__ == '__main__':
    if len(sys.argv) != 3:
        print "Usage: python prop_util.py <path to runtime.properties> <mydomain replacement>"
        sys.exit(1)
    runtime_filepath = sys.argv[1]
    print "Updating %s" % runtime_filepath
    p = Properties()
    p.load(open(runtime_filepath))
    print "****Properties before****"
    p.list()
    #Add/replace environment variables that begin with v_
    for key, value in [(key[2:], os.environ[key]) for key in os.environ if key.startswith("v_")]:
        print "Adding key %s: %s" % (key, value)
        p[key] = value
    #Replace mydomain in any values
    newdomain = sys.argv[2]
    for key, value in [(key, value) for (key, value) in p.iteritems() if "mydomain.edu" in value]:
        new_value = value.replace("mydomain.edu", newdomain)
        print "Changing key %s from %s to %s" % (key, value, new_value)
        p[key] = new_value
    #Set DB values based on docker-provided environment variables
    p['VitroConnection.DataSource.url'] = "http://db:8111/v1/graphs/sparql"
    p['VitroConnection.DataSource.username'] = '******'
    p['VitroConnection.DataSource.password'] = '******'
    print "****Properties after****"
    p.list()
    p.store(open(runtime_filepath,'w'))
Esempio n. 19
0
missingCoreMessages = Properties()
missingAfo = {}

for element in afoData:
    value = afoData[element]

    if coreMessagesData[element] is None:
        missingCoreMessages[element] = value

    elif coreMessagesData[
            element] is not None and value != coreMessagesData[element]:
        conflictTranslations[element] = value

    elif coreEnumData[element] is None:
        missingCoreEnum[element] = value

    elif (coreEnumData[element] != None and value != coreEnumData[element]):
        conflictTranslations[element] = value

for element in coreMessagesData.items():
    if element[0] not in afoData:
        missingAfo[element[0]] = element[1]

missingCoreMessages.store(open('results/missingCoreMessages.properties', 'w'))
missingCoreEnum.store(open('results/missingCoreEnum.properties', 'w'))
conflictTranslations.store(open('results/conflictTranslations.properties',
                                'w'))
missingAfoFile = open("results/missingAfo.json", "w")
json.dump(missingAfo, missingAfoFile)
missingAfoFile.close()
Esempio n. 20
0
    def write(keydict, savedir):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        loadfile = os.path.join(savedir, JitsiProperties.propertiesfile)
        savefile = loadfile
        if not os.path.exists(loadfile) and os.path.exists(JitsiProperties.path):
            print('Jitsi NOTICE: "' + loadfile + '" does not exist! Reading from:')
            loadfile = os.path.join(JitsiProperties.path, JitsiProperties.propertiesfile)
            print('\t"' + loadfile + '"')

        propkey_base = 'net.java.sip.communicator.plugin.otr.'
        p = Properties()
        p.load(open(loadfile))
        for name, key in keydict.items():
            if 'verification' in key and key['verification'] != '':
                verifiedkey = (propkey_base + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                               + '_publicKey_verified')
                p[verifiedkey] = 'true'
            if 'y' in key:
                pubkey = (propkey_base + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                          + '_publicKey')
                p.setProperty(pubkey, util.ExportDsaX509(key))
            if 'x' in key:
                protocol_id = 'UNKNOWN_'
                domain_id = 'unknown'
                servername = None
                if '@' in key['name']:
                    domainname = key['name'].split('@')[1]
                    domain_id = re.sub('[^a-zA-Z0-9_]', '_', domainname)
                    if domainname == 'chat.facebook.com':
                        protocol_id = 'Facebook_'
                    elif domainname == 'gmail.com' \
                            or domainname == 'google.com' \
                            or domainname == 'googlemail.com':
                        protocol_id = 'Google_Talk_'
                        servername = 'talk_google_com'
                    else:
                        protocol_id = 'Jabber_'
                else:
                    if key['protocol'] == 'prpl-icq':
                        protocol_id = 'ICQ_'
                        domain_id = 'icq_com'
                    elif key['protocol'] == 'prpl-yahoo':
                        protocol_id = 'Yahoo__'
                        domain_id = 'yahoo_com'
                # Writing
                pubkey = (propkey_base + protocol_id + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                          + '_' + domain_id + '_publicKey')
                p.setProperty(pubkey, util.ExportDsaX509(key))
                privkey = (propkey_base + protocol_id + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                           + '_' + domain_id + '_privateKey')
                p.setProperty(privkey, util.ExportDsaPkcs8(key))
		   
                if servername:
                    pubkey = (propkey_base + protocol_id + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                              + '_' + servername + '_publicKey')
                    p.setProperty(pubkey, util.ExportDsaX509(key))
                    privkey = (propkey_base + protocol_id + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                               + '_' + servername + '_privateKey')
                    p.setProperty(privkey, util.ExportDsaPkcs8(key))	
		   		
        p.store(open(savefile, 'w'))
Esempio n. 21
0
from pyjavaproperties import Properties

file_name="/Users/smandaki/PycharmProjects/DataDriven/data/config.properties"
output_Sterm=open(file_name, "a")
prop= Properties()
prop.setProperty(key='ValueOfPi', value="double,valueTesting")
prop.store(output_Sterm)
output_Sterm.close()

input_stream=open(file_name, "r")
prop1=Properties()
prop1.load(input_stream)
newval=prop.getProperty("ValueOfPi")
Str1=newval.split(',')
print(Str1[0])
print(Str1[1])
input_stream.close()

'''
file_path = "/Users/smandaki/PycharmProjects/DataDriven/data/config.properties"
output_file = open(file_path, 'a')
prop = Properties()
prop.setProperty(key="Users", value='Agent,Admin')
prop.store(output_file)
output_file.close()


input_stream = open(file_path, mode='r')
prop = Properties()
prop.load(input_stream)