예제 #1
0
def grab_web2py_frame():
    """Grab the path of the web2py framework and check its existence."""
    webframe = resolve_path(__file__,'../apps/scaffolding/win/web2py')
    webdotpy = resolve_path(__file__,'../apps/scaffolding/common/web2py.py')
    check_file_exist(webdotpy)
    check_file_exist(webframe)
    return webframe, webdotpy
예제 #2
0
def grab_web2py_script_path(which_app, w_os):
    """
    For a list of operating systems, get the path of the web2py.py
        script for a specified application.
    """
    if w_os == "mac":
        path_form = "../apps/web_apps/{os}/{app}/web2py/{maaa}/web2py.py"
        path_form = resolve_path(__file__, path_form)
        extra = "web2py.app/Contents/Resources"
        path = path_form.format(os=w_os, app=str(which_app), maaa=extra)
    else:
        path_form = "../apps/web_apps/{os}/{app}/web2py/web2py.py"
        path_form = resolve_path(__file__, path_form)
        path = path_form.format(os=w_os, app=str(which_app))
    print "    web2py script path: {}\n".format(path)
    return path
예제 #3
0
def grab_view_path(which_app, w_os):
    """Grabs the path of the view file to be modified."""
    if w_os == 'mac':
        app_dir = '../apps/web_apps/{os}/{app}/web2py/{ext}/applications'
        app_dir = resolve_path(__file__, app_dir)
        extra = 'web2py.app/Contents/Resources'
        app_dir = app_dir.format(os=w_os, app=which_app, ext=extra)
        file_loc = 'MKE_Static_Name/views/default/index.html'
        path = os.path.join(app_dir, file_loc)
    else:
        app_dir = '../apps/web_apps/{os}/{app}/web2py/applications'
        app_dir = resolve_path(__file__, app_dir)
        app_dir = app_dir.format(os=w_os, app=which_app)
        file_loc = 'MKE_Static_Name/views/default/index.html'
        path = os.path.join(app_dir, file_loc)
    return path
예제 #4
0
def grab_file_paths(tif_dir):
    """Grabs the paths of images to be processed and puts them in a list."""
    image_path_list = []
    tif_path = resolve_path(__file__, tif_dir)
    for root, dirs, files in os.walk(tif_path, topdown=False):
        del dirs
        for name in files:
            image_path_list.append((os.path.join(root, name)))
    return image_path_list
예제 #5
0
def grab_txt(image_name, out_path):
    """Grabs metadata for a specified image and stores it as a dictionary."""
    import ast

    image_path_form = out_path + "/{name}/{name}.txt"
    image_path_form = resolve_path(__file__, image_path_form)
    with open(image_path_form.format(name=image_name), "r") as meta_f:
        dic_str = meta_f.read()
        dictionary = ast.literal_eval(dic_str)
    return dictionary
예제 #6
0
def grab_image_paths(processed_path):
    """Returns a list of processed png image paths"""
    image_path_list = []
    processed_image_path = resolve_path(__file__, processed_path)
    for root, dirs, files in os.walk(processed_image_path,
                                     topdown=False):
        del dirs
        for name in files:
            if name[-4:] == '.png':
                image_path_list.append((os.path.join(root, name)))
    return image_path_list
예제 #7
0
def create_bat(out_path, num):
    """Creates a bat file to start the web2py server."""
    mkebat = resolve_path(__file__, '../apps/scaffolding/common/MKE_PT_.bat')
    check_file_exist(mkebat)
    shutil.copy(mkebat, out_path)
    old_name = os.path.join(out_path, 'MKE_PT_.bat')
    exe_name = 'MKE_PT_{}.bat'.format(num)
    new_name = os.path.join(out_path, exe_name)
    print "    ...P{} bat file created...".format(num)
    os.rename(old_name, new_name)
    return None
예제 #8
0
def create_python_scripts(up_cmds, commit_cmd, which_app, pop_path):
    """
    Creates a script, from a series of commands,
        to be read by an interpreter.
    """
    path_form = resolve_path(__file__, pop_path)
    path = os.path.abspath(path_form.format(which_app))
    create_dirs(path_form[:-15])
    with open(path, "w") as python_file:
        for cmd in up_cmds:
            python_file.write(cmd + "\n")
        python_file.write("\n" + commit_cmd + "\n")
    return path
예제 #9
0
def grab_out_paths(num_apps):
    """
    From the number of applications necessary,  create a list
        of pathnames where we will create windows applications.
    """
    out_dir = resolve_path(__file__,'../apps/web_apps/win/{pat}')
    project_part = 'P{}'
    out_paths = []
    for num in range(1, num_apps + 1):
        strin = project_part.format(str(num))
        print "{part}, preparing for generation.".format(part=strin)
        out_paths.append(out_dir.format(pat=strin))
    return out_paths
예제 #10
0
def delete_directories(directory_dictionary):
    """Resets system so further files may be deleted."""
    print "\nResetting system...\n"
    directory_keys = directory_dictionary.keys()
    for directory in directory_keys:
        path = resolve_path(__file__, directory_dictionary[directory])
        print "Deleteing {}.".format(path)
        if exists(path):
            rmtree(path)
        else:
            print "    But it doesn't exist..."
    print "\nFinished resetting system...\n"
    return None
예제 #11
0
def grab_out_paths(number_apps, app_path):
    """
    From the number of applications necessary,  create a list
        of pathnames where we will create linux applications.
    """
    out_dir = resolve_path(__file__, app_path)
    project_part = 'P{}'
    os = "linux"
    out_paths = []
    for num in range(1, number_apps + 1):
        strin = project_part.format(str(num))
        print "{part}, preparing for generation.".format(part=strin)
        out_paths.append(out_dir.format(os=os, pat=strin))
    return out_paths
예제 #12
0
def delete_dirs_no_print(directory_dictionary):
    """
    Resets system so further files may be deleted.
        Does not print status.
    """
    directory_keys = directory_dictionary.keys()
    for directory in directory_keys:
        path = resolve_path(__file__, directory_dictionary[directory])
        if exists(path):
            print "Deleteing `{}`.".format(path)
            rmtree(path)
        else:
            pass
    return None
예제 #13
0
def grab_out_paths(image_path_list, adict):
    """
    Returns a list of filenames and the outpaths of processed images.


    """
    out_dir = resolve_path(__file__,  adict["out_path"] + "/{pat}")
    image_name_form = adict["image_name_form"]
    out_paths = []
    file_names = []
    for num in range(len(image_path_list)):
        strin = image_name_form.format(str(num).zfill(4))
        file_names.append(strin)
        out_paths.append(out_dir.format(pat=strin))
    return out_paths, file_names
예제 #14
0
def write_meta_data(data, meta_path):
    """
    Records sizes of all the pngs/tiffs in files that can later
        be read as dictionaries.
    ../data/png_sizes.txt
    ../data/tif_sizes.txt
    """
    meta_path = resolve_path(__file__,  meta_path)
    if not os.path.exists(meta_path):
        os.makedirs(meta_path)
    meta_path += "/{}.txt"
    keys = data.keys()
    for key in keys:
        with open(meta_path.format(key), 'w') as meta_file:
            sizes = str(data[key]) + '\n'
            meta_file.write(sizes)
    return None
예제 #15
0
def grab_scaffold_app(version):
    """Grab the path of our scaffolding and check its existence."""
    mkever = '../apps/scaffolding/version/MKE_v{}'.format(version)
    mkever = resolve_path(__file__, mkever)
    check_file_exist(mkever)
    return mkever