示例#1
0
def rename_project(new_name, new_domain):
    """
    Renames all directories and files to the new name and domain and adapts
    the code accordingly.
    """
    old_project_dir = project_dir()
    new_project_dir = os.path.join(os.path.dirname(project_dir()), new_name)
    new_package_name = '.'.join([new_domain, new_name])

    shutil.move("%s.pro" % app_name(), "%s.pro" % new_name)

    files = [
        "main.h", "android/src/org/kde/necessitas/origo/QtActivity.java",
        "android/AndroidManifest.xml"
    ]
    for fn in files:
        python_sed(package_name(), new_package_name, fn)

    files = [
        "%s.pro" % new_name, "android/AndroidManifest.xml",
        "android/res/values/strings.xml", "android/build.xml", "main.h"
    ]
    for fn in files:
        python_sed(app_name(), new_name, fn)

    shutil.move(old_project_dir, new_project_dir)
    os.chdir(new_project_dir)

    conf = ConfigParser.ConfigParser()
    conf.read(naming_config_file())
    conf.set("General", "app_name", new_name)
    conf.set("General", "package_name", new_package_name)
    with file(naming_config_file(), "w") as fobj:
        conf.write(fobj)
示例#2
0
def zip_app():
    """Remove the old zip archive and create the new one for APP_DIR."""

    if not compile_app_directory():
        sys.exit(0)

    print "Removing old zip archive..."
    print
    try:
        os.remove(app_zip_file())
    except OSError:
        pass

    print "Creating new zip archive at:"
    print app_zip_file()

    zf = zipfile.PyZipFile(app_zip_file(), mode='w')
    print '******', project_dir()
    os.chdir(project_dir())
    try:
        zf.writepy(app_dir(), 'app')
        root_len = len(project_dir())
        for root, dirs, files in os.walk(app_dir()):
            dir_path_from_root = root[root_len:]
            for f in files:
                if not (f.endswith('.py') or f.endswith('.pyc')):
                    fullpath = os.path.join(root, f)
                    archive_name = os.path.join(dir_path_from_root, f)
                    zf.write(fullpath, archive_name)
    finally:
        zf.close()

    print "Done."
示例#3
0
def rename_project(new_name, new_domain):
    """
    Renames all directories and files to the new name and domain and adapts
    the code accordingly.
    """
    old_project_dir = project_dir()
    new_project_dir = os.path.join(os.path.dirname(project_dir()), new_name)
    new_package_name = '.'.join([new_domain, new_name])

    shutil.move("%s.pro" % app_name(), "%s.pro" % new_name)

    files = ["main.h",
             "android/src/org/kde/necessitas/origo/QtActivity.java",
             "android/AndroidManifest.xml"]
    for fn in files:
        python_sed(package_name(), new_package_name, fn)

    files = ["%s.pro" % new_name,
             "android/AndroidManifest.xml",
             "android/res/values/strings.xml",
             "android/build.xml",
             "main.h"]
    for fn in files:
        python_sed(app_name(), new_name, fn)

    shutil.move(old_project_dir, new_project_dir)
    os.chdir(new_project_dir)

    conf = ConfigParser.ConfigParser()
    conf.read(naming_config_file())
    conf.set("General", "app_name", new_name)
    conf.set("General", "package_name", new_package_name)
    with file(naming_config_file(), "w") as fobj:
        conf.write(fobj)
示例#4
0
def zip_libs():
    """Remove the old zip archive and create the new one from libs."""

    print "Removing old zip archive..."
    print
    try:
        os.remove(libs_zip_file())
    except OSError:
        pass

    print "Creating new zip archive at:"
    print libs_zip_file()

    zf = zipfile.ZipFile(libs_zip_file(), mode='w')
    try:
        root_len = len(project_dir())
        for root, dirs, files in os.walk(project_libs_dir()):
            dir_path_from_root = root[root_len:]
            for f in files:
                fullpath = os.path.join(root, f)
                archive_name = os.path.join(dir_path_from_root, f)
                zf.write(fullpath, archive_name)
    finally:
        zf.close()

    print "Done."