Esempio n. 1
0
    def __init__(self, root_dir):
        gradle_properties = property.parse(
            os.path.join(root_dir, 'gradle.properties'))
        version_properties = property.parse(
            os.path.join(root_dir, ARTIFACTORY_FILE_NAME))

        ### 读取在 version_properties 中配置的 modules
        ### 适配如 api 'group:lib:version'
        ### 适配如 api project(':lib')
        module_array = get_deploy_modules(root_dir, version_properties)

        self.root_dir = root_dir
        # 过滤含有build.gradle文件的文件夹(为module),并解析出build.gradle中对当前工程中各module的依赖项
        self.modules = {}
        ### 匹配当前groupId的依赖项
        self.pattern = re.compile(r'.*(ompile|pi|mplementation).*((' +
                                  gradle_properties.get('maven_groupId') +
                                  ')|(:(' + '|'.join(module_array) + '):)).*')

        gradle_array = get_all_gradle_path(version_properties, root_dir,
                                           module_array)

        for module_name, gradle in gradle_array.items():
            self.modules[module_name] = read_gradle_dependencies(
                self.pattern, module_name, gradle, module_array)

        self.sorted_modules = self.sort_by_dependency_relationship(
            version_properties)
Esempio n. 2
0
    def __init__(self, root_dir):
        gradle_properties = property.parse(os.path.join(root_dir, 'gradle.properties'))
        version_properties = property.parse(os.path.join(root_dir, ARTIFACTORY_FILE_NAME))
        self.root_dir = root_dir
        # 过滤含有build.gradle文件的文件夹(为module),并解析出build.gradle中对当前工程中各module的依赖项
        self.modules = {}
        ### 匹配当前groupId的依赖项
        self.pattern = re.compile(r'.*ompile.*((' + gradle_properties.get('maven_groupId') + ')|(maven_groupId)).*')
        for file in os.listdir(root_dir):
            if version_properties.has_key(file):
                path = os.path.join(root_dir, file)
                gradle = os.path.join(path, 'build.gradle')
                if os.path.isdir(path) and os.path.isfile(gradle):
                    self.modules[file] = read_gradle_dependencies(self.pattern, gradle)

        self.sorted_modules = self.sort_by_dependency_relationship()
 def __init__(self, embeddings_path=None):
     file_path = Path + '/conf/system.properties'
     self.props = propertyUtil.parse(file_path)
     if embeddings_path is None:
         embeddings_path = self.props.get("EMBEDDING_PATH")
     model = word2vec.load(Path + '/' + embeddings_path)
     self.model = model
     self.embeddings = model.vectors.tolist()
     self.vocab = model.vocab.tolist()
     self.wordsMap = self._build(self.vocab)
Esempio n. 4
0
    def setTablePhases(self):
        propertyFile = self.__workingPath + self.__properFile
        props = property.parse(propertyFile)
        if self.__properDict['tablesPhases'] == '0':
            props.put('tablesPhases', '1')

        if self.__properDict['tablesPhases'] == '1':
            props.put('tablesPhases', '2')

        if self.__properDict['tablesPhases'] == '2':
            props.put('tablesPhases', '0')
Esempio n. 5
0
    def __init__(self, root_dir):
        gradle_properties = property.parse(
            os.path.join(root_dir, 'gradle.properties'))
        version_properties = property.parse(
            os.path.join(root_dir, ARTIFACTORY_FILE_NAME))
        self.root_dir = root_dir
        # 过滤含有build.gradle文件的文件夹(为module),并解析出build.gradle中对当前工程中各module的依赖项
        self.modules = {}
        ### 匹配当前groupId的依赖项
        self.pattern = re.compile(
            r'.*ompile.*((' + gradle_properties.get('maven_groupId') +
            ')|(maven_groupId)|(rootProject\.ext\.deps.)).*')
        for file in os.listdir(root_dir):
            if version_properties.has_key(file):
                path = os.path.join(root_dir, file)
                gradle = os.path.join(path, 'build.gradle')
                if os.path.isdir(path) and os.path.isfile(gradle):
                    self.modules[file] = read_gradle_dependencies(
                        self.pattern, gradle)

        self.sorted_modules = self.sort_by_dependency_relationship()
    def __init__(self, word2VecPath=None, stopWordPath=None, load=True):
        file_path = Path + '/conf/system.properties'
        self.props = propertyUtil.parse(file_path)
        if word2VecPath is None:
            self.word2VecPath = self.props.get("EMBEDDING_PATH")
        if stopWordPath is None:
            self.stopWordPath = self.props.get("STOPWORDS_PATH")
        self.stopWords = self._getStopWords()

        if load:
            #print word2VecPath
            self.word2Vec = Word2Vector(word2VecPath)
Esempio n. 7
0
 def __setEnvs(self):
     # get setting from sys environment
     envDist = os.environ
     for key in self.__properKeys:
         self.__properDict[key] = envDist.get(key)
     # get setting from property file if it's null in sys environment
     propertyFile = self.__workingPath + self.__properFile
     props = property.parse(propertyFile)
     for key in self.__properKeys:
         if self.__properDict[key] is None or not self.__properDict[
                 key].strip():
             self.__properDict[key] = props.get(key)
Esempio n. 8
0
 def __init__(self):
     try:
         properies = property.parse('config/db.properties')
     except Exception as e:
         print('读取配置失败:', e)
     try:
         print('开始链接')
         self.conn = pymysql.connect(host=properies.get('host'),
                                     port=properies.get('port'),
                                     user=properies.get('user'),
                                     passwd=properies.get('passwd'),
                                     db=properies.get('database'),
                                     charset=properies.get('charset'))
     except Exception as e:
         print("数据库连接失败:", e)
     else:
         print('数据库连接成功')
         self.cur = self.conn.cursor()
Esempio n. 9
0
def test_property():
    properties = property.parse('config/db.properties')
    print(properties.get('host'))
Esempio n. 10
0
                find_reverse_dependency_module_4_deploy(
                    modules, i, rev_modules, gradle_properties, maven_type)


#读取工程中的依赖关系
def get_project_dependencies(root_dir):
    return Dependency(root_dir)


#在工程根目录执行以下代码,打印出当前工程下的依赖关系:
# python python_tools/dependency_reader.py
if __name__ == '__main__':
    project_abs_path = os.path.abspath(os.curdir)  #默认为当前目录
    dependency = get_project_dependencies(project_abs_path)
    if len(sys.argv) > 1:
        gradle_version_properties = property.parse(
            os.path.join(project_abs_path, 'gradle.properties'))
        deploy_maven_type = 'snapshot'
        if len(sys.argv) > 2:
            deploy_maven_type = sys.argv[2]
        revert_dependencies = dependency.get_all_reverse_dependencies_4_deploy(
            sys.argv[1], gradle_version_properties, deploy_maven_type)
        print 'revert dependencies:'
        print revert_dependencies
    else:
        module_dependencies = dependency.modules
        for key in module_dependencies:
            print "module:" + key
            print module_dependencies[key]
            print ''

        print '----------------------------------------------------'
BUILD_DATE = args.BUILD_DATE
BUILD_VERSION = args.BUILD_VERSION
installationPkgChaincodeName = args.installationPkgChaincodeName
installationPkgChaincodeVersion = args.installationPkgChaincodeVersion
SWIFT_IDENTITY_SERVICE_ADMIN_BIND_PORT = args.SWIFT_IDENTITY_SERVICE_ADMIN_BIND_PORT
OPENSTACK_SWIFT_USERNAME = args.OPENSTACK_SWIFT_USERNAME
OPENSTACK_SWIFT_PASSWORD = args.OPENSTACK_SWIFT_PASSWORD
OPENSTACK_SWIFT_PROJECTNAME = args.OPENSTACK_SWIFT_PROJECTNAME
OPENSTACK_SWIFT_PROJECTDOMAIN = args.OPENSTACK_SWIFT_PROJECTDOMAIN
OPENSTACK_SWIFT_CONTAINERNAME = args.OPENSTACK_SWIFT_USERNAME
TFS_API_CONFIGFILE_NAME = args.TFS_API_CONFIGFILE_NAME
APPLICATION_TARGET_ENV = args.APPLICATION_TARGET_ENV

file_path = installationPkgApplicationArtifactsRoot + '/' + TFS_API_CONFIGFILE_NAME
print("file_path:" + file_path)
props = property.parse(file_path)
props.put('spring.profiles.active', APPLICATION_TARGET_ENV)
props.put('server.port', TFS_API_SERVICE_PORT)
props.put(
    'spring.datasource.url',
    'jdbc:mysql://' + externalIp + ':' + MYSQL_BIND_ACCESS_PORT + '/' +
    tfsApiDbName + '?useUnicode=true&characterEncoding=utf-8&useSSL=false')
props.put('spring.datasource.username', tfsApiDbUserName)
props.put('spring.datasource.password', tfsApiDbUserPassword)
props.put('spring.mail.host', MAIL_HOST)
props.put('spring.mail.username', MAIL_USERNAME)
props.put('spring.mail.password', MAIL_PASSWORD)
props.put('mail.sender', MAIL_SENDER)
props.put('mail.receiver', MAIL_RECEIVER)
props.put('build.date', BUILD_DATE)
props.put('build.version', BUILD_VERSION)
Esempio n. 12
0
def main():
#    file_path1 = 'english.prop' # English
#    file_path2 = 'chinese.prop' # Chinese
    file_path1 = sys.argv[1]
    file_path2 = sys.argv[2]
    props1 = property.parse(file_path1)
    props2 = property.parse(file_path2)
#    print(props1.properties)
#    print(props2.properties)
    keys_not_in_chinese = []
    for key1 in props1.properties.keys():
        has_chinese_key = False
        for key2 in props2.properties.keys():
#            print("{}, {}".format(key1, key2))
            if key1 == key2:
                has_chinese_key = True
                break
        if not has_chinese_key:
            keys_not_in_chinese.append(key1)
    keys_not_in_chinese = sorted(keys_not_in_chinese)
    print(keys_not_in_chinese)
    print("Found {} keys different".format(len(keys_not_in_chinese)))
    current_time = time.time()
#    diff_props_file_content = "# Generated by Translation Diff Generator\n#\n# Date: {}\n# English translation count: {}\n# Chinese translation count: {}\n# Diff count: {}\n#\n\n"\
#            .format(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(current_time)), len(props1.properties), len(props2.properties), len(keys_not_in_chinese))
    diff_props_file_content = ""
    zh_diff_props_file_content = diff_props_file_content
    keys_not_in_chinese_len = len(keys_not_in_chinese)
    i = 0
    """
    top_window = tk.Tk()
    input_entry = tk.Entry(top_window, bd=5)
    input_entry.pack(side = tk.LEFT)
    input_entry_inputed_text = ""
    def on_click():
        input_entry_inputed_text = input_entry.get()
        main_thread_event.set()
    button = tk.Button(top_window, text = "OK", command = on_click)
    button.pack(side = tk.RIGHT)
    """
    '''
    def thread_entry():
        top_window = tk.Tk()
        input_entry = tk.Entry(top_window, bd=5)
        input_entry.pack(side = tk.LEFT)
        input_entry_inputed_text = ""
        def on_click():
            input_entry_inputed_text = input_entry.get()
            main_thread_event.set()
        button = tk.Button(top_window, text = "OK", command = on_click)
        button.pack(side = tk.RIGHT)
        top_window.mainloop()
    gui_thread = threading.Thread(name = "GUI Thread", target = thread_entry)
    gui_thread.start()
    main_thread_event = threading.Event()
    '''
    for key in keys_not_in_chinese:
        print("Current: {}/{}".format(i, keys_not_in_chinese_len))
        value = props1.get(key)
        spider = translator.BaiduTranslator(value)
        print("Translating: {}".format(value))
        zh_value = spider.run()
        print("Translated: {}".format(zh_value))
#        print("Your input:", end = '')
#        zh_value_inputed = input("Your input: ")
#        top_window.title("Translated: {}".format(zh_value))
#        print("Waiting for the input to finish...")
#        main_thread_event.wait()
#        main_thread_event.clear()
#        zh_value_inputed = input_entry_inputed_text
#        input_entry.select_clear()
#        if len(zh_value_inputed) == 0:
#            zh_value_inputed = zh_value
#        print("Result: {}".format(zh_value_inputed))
        diff_props_file_content += key
        diff_props_file_content += '='
        diff_props_file_content += value
        diff_props_file_content += '\n'
        zh_diff_props_file_content += key
        zh_diff_props_file_content += '='
#        zh_diff_props_file_content += zh_value_inputed
        zh_diff_props_file_content += zh_value
        zh_diff_props_file_content += '\n'
        diff_props_save_file = open("diff.prop.save", "w")
        diff_props_save_file.write(diff_props_file_content)
        diff_props_save_file.close()
        zh_diff_props_save_file = open("zh_diff.prop.save", "w")
        zh_diff_props_save_file.write(zh_diff_props_file_content)
        zh_diff_props_save_file.close()
        i += 1
    diff_props_file = open("diff.prop", "w")
    diff_props_file.write(diff_props_file_content)
    diff_props_file.close()
    zh_diff_props_file = open("zh_diff.prop", "w")
    zh_diff_props_file.write(zh_diff_props_file_content)
    zh_diff_props_file.close()
for file in fz.namelist():
    # print(file)
    fz.extract(file, path2)
print('Done')

print('Decompression old resource_en.jar file...', end='', flush=True)
fzo = zipfile.ZipFile(filename_cn, 'r')
for file in fzo.namelist():
    # print(file)
    fzo.extract(file, path2_cn)
print('Done')

print('translate new resource_en.jar file...', end='', flush=True)
for file in fz.namelist():
    if (file.endswith(".properties")):
        props = property.parse(path2 + '\\' + file)
        keys = props.keys
        for fileCN in fzo.namelist():
            if (fileCN == file):
                propsCN = property.parse(path2_cn + '\\' + file)
                keysCN = propsCN.keys
                for key in keys:
                    # print(len(keys))
                    # print(file + "=======>" + key + "=" + props.get(key))
                    if (propsCN.has_key(key)):
                        props.set(key, propsCN.get(key))
        props.save()
        keys.clear()
print('Done')

print('Packing Translated file...', end='', flush=True)