Пример #1
0
def new_log(position, log):
    #
    FM.change_directory('data/ordered/logs/')
    #Find the
    files = FM.list_files()
    file_chsn = 0
    for i in range(0, len(files)):
        for n in range(0, len(files[i])):
            if files[i][n] == '.':
                file_num = int(files[i][:n])
                if file_num > file_chsn:
                    file_chsn = file_num
    if FM.file_length(str(file_chsn)) == 10:
        file_chsn += 1
    FM.append_substring(str(file_chsn), log)
    #
    FM.change_directory('../dates/')
    FM.append_substring(str(file_chsn), get_time())
    FM.change_directory('../coord/')
    # WILL BE EDITED IN FUTURE
    FM.append_substring(str(file_chsn), '40.5698452,-105.10956120000003')
    index = FM.file_length(str(file_chsn)) - 1
    FM.change_directory('../../' + position)
    FM.append_substring('notes', str(file_chsn) + ',' + str(index) + ',0')
    # go back to surface folder
    FM.change_directory('../' * (LP.folder_layers(position) + 1))
Пример #2
0
def dealWithIconPath(badge_path=""):
    """外部入口"""
    log_utils.info("进入appicon处理程序---开始处理icon")
    # 检查资源
    tempfile = file_manager.getFullPath("upload/icon")
    file_manager.clear(tempfile)

    # 1、获取icon的全路径文件夹
    iconPath = file_manager.getFullPath(Index.root_icon)

    # 2、获取该路径下的所有文件
    icons = file_manager.list_files(iconPath, [], ".DS_Store")
    if len(icons) == 0:
        log_utils.info("还没有上传appicon资源文件,请上传之后操作!")
        return 101
    else:
        # 如果数组不为空,取出第一个元素
        # 获取到icon文件
        for filename in icons:
            if ".png" in filename:
                appIconDir = filename

    iOSIconSizes = [
        ("icon-20@2x", 40),
        ("icon-20@3x", 60),
        ("icon-29", 29),
        ("icon-29@2x", 58),
        ("icon-29@3x", 87),
        ("icon-40@2x", 80),
        ("icon-40@3x", 120),
        ("icon-60@2x", 120),
        ("icon-60@3x", 180),
        ("icon-1024", 1024),
        ("icon-40", 40),
        ("icon-72", 72),
        ("icon-29-ipad", 29),
        ("icon-72@2x", 144),
        ("icon-76", 76),
        ("icon-76@2x", 152),
        ("icon-83.5@2x", 167),
        ("icon-57", 57),
        ("icon-57@2x", 114),
        ("icon-20-ipad", 20),
        ("icon-20-ipad@2x", 40),
        ("icon-50", 50),
        ("icon-50@2x", 100),
        ("icon-29-ipad@2x", 58),
    ]
    AndroidIconList = [("drawable-ldpi", 36, "icon-36"),
                       ("drawable-mdpi", 48, "icon-48"),
                       ("drawable-hdpi", 72, "icon-72"),
                       ("drawable-xhdpi", 96, "icon-96"),
                       ("drawable-xxhdpi", 144, "icon-144"),
                       ("drawable-xxxhdpi", 192, "icon-192"),
                       ("drawable", 512, "icon-512")]

    processingIcons(appIconDir, "ios", iOSIconSizes)
    processingIcons(appIconDir, "android", AndroidIconList)
    make_archiveWithInfo()
Пример #3
0
def gather_paths(position):
    # cd to position and gather log paths and strengths
    FM.change_directory('data/' + position)
    paths = FM.get_all('notes')

    # separate paths information by comma and put into list
    for i in range(0, len(paths)):
        paths[i] = paths[i].split(',')
        paths[i].insert(2, i)
        for n in range(0, len(paths[i])):
            paths[i][n] = int(paths[i][n])

    # find number of layers position is from data folder
    layers = LP.folder_layers(position)

    # cd back to logs folder (could be any of the ordered data folders)
    FM.change_directory('../' * layers + 'ordered/logs/')
    # get all file names in logs folder
    file_names = FM.list_files()

    # find number in each file name (take out .txt and convert to int)
    for i in range(0, len(file_names)):
        for n in range(0, len(file_names[i])):
            if file_names[i][n] == '.':
                file_names[i] = int(file_names[i][:n])
                break

    # file_paths is for knowing the filename for the first
    file_paths = []
    log_paths = []

    # store each necessary file name in file_paths
    for i in range(0, len(file_names)):
        for n in range(0, len(paths)):
            if paths[n][0] == file_names[i]:
                file_paths.append(file_names[i])
                break

    # setup log_paths for each file in file_paths
    for i in range(0, len(file_paths)):
        log_paths.append([])

    # organize log and strength with their respective file
    for i in range(0, len(file_paths)):
        for n in range(0, len(paths)):
            if paths[n][0] == file_paths[i]:
                log_paths[i].append([paths[n][1], paths[n][2], paths[n][3]])

    # cd back to bumplog folder
    FM.change_directory('../../../')

    return file_paths, log_paths
Пример #4
0
def getpath(dir):
    # 2、获取该路径下的所有文件
    icons = file_manager.list_files(dir, [], ".DS_Store");
    if len(icons) == 0:
        log_utils.info("还没有上传appicon资源文件,请上传之后操作!")
        return 101
    else:
        # 如果数组不为空,取出第一个元素
        # 获取到icon文件
        for filename in icons:
            if ".png" in filename:
                appIconDir = filename
                return  appIconDir
Пример #5
0
@author: RiguiFD
"""

import file_manager as fm
import signal_processing as sp
import pandas as pd

# Open Parameter File. This 'FullParam' dictionary has most of the Parameters
# That shall be used for NVH_ML

full_param_path = 'C:\\Users\\riguifd\\Documents\\GitHub\\NVH_ML\\NVH_ML\\param.yaml'

main_param = fm.load_yaml_file(full_param_path)

# Get All TDMS file names and entire file path from target directory
list_of_files = fm.list_files(main_param['list_files'])

folder_path = main_param['list_files']['folder_path']
list_of_file_paths = [folder_path + file for file in list_of_files]

full_result = pd.DataFrame()

for file_path in list_of_file_paths:
    print(file_path)
    sgnl, time, sgnl_param = fm.load_signal_from_tdms(
        file_path, main_param['load_signal_from_tdms'])
    print(sgnl_param['f_name'])
    result = pd.DataFrame({'file_name': [sgnl_param['f_name']]})
    for test in main_param['analysis']:
        print(test['test_name'])
        slcd_sgnl, slcd_time, slcd_sgnl_par = fm.slicing_by_time(
Пример #6
0
def dealWithSplashPath():
    log_utils.info("进入splash处理程序---开始处理splash")
    # 检查资源
    tempfile = file_manager.getFullPath("upload/splash/ios")
    file_manager.clear(tempfile)  #去掉DS_Store文件

    # 1、获取icon的全路径文件夹
    iosIconPath = file_manager.getFullPath(Index.root_splash + "/ios")
    androidIconPath = file_manager.getFullPath(Index.root_splash + "/android")

    # 2、获取该路径下的所有文件
    icons = file_manager.list_files(iosIconPath, [], ".DS_Store")
    if len(icons) == 0:
        log_utils.info("还没有上传splash资源文件,请上传之后操作!")
        return 101
    else:
        # 如果数组不为空,取出第一个元素
        # 获取到icon文件
        for filename in icons:
            if "L.png" in filename:
                launchimageL = filename
            elif "P.png" in filename:
                launchimageP = filename

    log_utils.info(launchimageL)
    log_utils.info(launchimageP)

    # ios 需要提供尺寸 1125x2436  和 2436x1125
    # android 需要提供 1920x1080 和 1080x1920

    iOSSplashSizes = [("Default-Portrait-2436h", (1125, 2436)),
                      ("Default-Landscape-2436h", (2436, 1125)),
                      ("Default-Portrait@3x", (1242, 2208)),
                      ("Default-667h@2x", (750, 1334)),
                      ("Default-Landscape@3x", (2208, 1242)),
                      ("Default-Portrait@2x", (1536, 2048)),
                      ("Default-Landscape", (1024, 768)),
                      ("Default-Landscape@2x", (2048, 1536)),
                      ("Default", (320, 480)), ("Default@2x", (640, 960)),
                      ("Default-568h@2x", (640, 1136)),
                      ("Default-Portrait", (768, 1024))]

    AndroidSplashList = [("drawable_ldpi", (320, 240)),
                         ("drawable_mdpi", (480, 320)),
                         ("drawable_hdpi", (800, 480)),
                         ("drawable_xhdpi", (1280, 720)),
                         ("drawable_xxhdpi", (1920, 1080)),
                         ("drawable_ldpi", (240, 320)),
                         ("drawable_mdpi", (320, 480)),
                         ("drawable_hdpi", (480, 800)),
                         ("drawable_xhdpi", (720, 1280)),
                         ("drawable_xxhdpi", (1080, 1920))]

    processingWithSplash(launchimageL, "ios", iOSSplashSizes)
    processingWithSplash(launchimageP, "ios", iOSSplashSizes)

    processingAndroidSplash(launchimageL, "android", AndroidSplashList)
    processingAndroidSplash(launchimageP, "android", AndroidSplashList)

    log_utils.printf()
    print("所有闪屏图片处理完毕,接下来是打包过程,请稍后....")

    make_archiveWithInfo()
Пример #7
0
def main():
    # Get to Blog folder
    FM.change_directory('../../content/blog/')

    # Find each post
    files = FM.list_files()
    posts = []

    for i in range(0,len(files)):
        if files[i] == 'index.md':
            del files[i]
            break

    for i in range(0,len(files)):
        if files[i][-3:] == '.md':
            posts.append({'url' : files[i][:-3]})

    # ----------- Search each file for unordered metadata ----------- #
    find_meta = ['title', 'author_id', 'date', 'description']
    for i in range(0,len(posts)):
        meta = []
        for j in range(0,len(find_meta)):
            meta.append(find_meta[j])

        lines = FM.get_all(posts[i]['url'] + '.md')

        # Search front matter for required metadata
        encountered_before = False
        for j in range(0,len(lines)):
            ln = lines[j].strip()
            if ln == '+++':
                if encountered_before:
                    lines = lines[j+1:]
                    break
                else:
                    encountered_before = True
            # if inside frontmatter
            if encountered_before:
                # see if current line contains required metadata
                for k in range(0,len(meta)):
                    if ln[:len(meta[k])] == meta[k]:
                        # Find the key value separator in line
                        separator = -1
                        value = ''
                        for n in range(len(meta[k]), len(ln)):
                            if ln[n] == '=':
                                value = ln[n+1:].strip()
                        posts[i][meta[k]] = value
                        del meta[k]
                        break
                # If found all metadata
                if len(meta) == 0:
                    # Find end of Front Matter before breaking
                    for k in range(j,len(lines)):
                        if lines[k].strip() == '+++':
                            lines = lines[k+1:]
                            break
                    break

        # ERROR: if could not find all required metadata in frontmatter
        if len(meta) > 0:
            print('\nERROR:')
            print('Could not find ', end='')
            # print each item not able to be found in frontmatter
            for j in range(0,len(meta)):
                print(meta[j], end='')
                # if not last item in meta, print comma separator
                if j < (len(meta) - 1):
                    print(', ', end='')
            print(' in file ' + posts[i] + '.md')
            raise SystemExit

        # Convert date to string in new key
        posts[i]['datestr'] = date_to_string(posts[i]['date'])

        # Get read time from markdown content
        posts[i]['readtime'] = str(get_readtime(lines))
    # --------------------------------------------------------------- #

    # Once finished gathering metadata for each post

    # Arrange blog posts by date
    posts = arrange_by_date(posts)

    # Go back to config folder, then go into toml folder
    FM.change_directory('../../config/toml/')

    # Blog data file name
    file_name = 'blog.toml'

    # Make sure each required item has quotations surrounding them
    rqd_quotes = ['title', 'author_id', 'url', 'description', 'readtime', 'datestr']
    for i in range(0,len(posts)):
        for j in range(0,len(rqd_quotes)):
            key_val = posts[i][rqd_quotes[j]]
            if (key_val[0] == '\'' or key_val[0] == '\"') and key_val[0] == key_val[-1]:
                continue
            else:
                new_string = '\"'
                for k in range(0,len(key_val)):
                    if key_val[k] == '\"':
                        new_string += '\\"'
                    else:
                        new_string += key_val[k]
                new_string += '\"'
                posts[i][rqd_quotes[j]] = new_string


    # TOML table name for each blog post
    table_name = '[[extra.blog]]'

    # Lines to be written to new TOML file
    toml_lines = []
    for i in range(0,len(posts)):
        toml_lines.append(table_name)
        for key, value in posts[i].items():
            toml_lines.append('\t' + str(key) + ' = ' + str(value))
        toml_lines.append('')

    toml_files = FM.list_files()

    for i in range(0,len(toml_files)):
        if file_name == toml_files[i]:
            FM.remove_file(toml_files[i])

    for i in range(0,len(toml_lines)):
        FM.append_substring(file_name, toml_lines[i])