本文整理汇总了Python中rapt.plat.path函数的典型用法代码示例。如果您正苦于以下问题:Python path函数的具体用法?Python path怎么用?Python path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_tree
def make_tree(src, dest):
src = plat.path(src)
dest = plat.path(dest)
def ignore(dir, files):
rv = [ ]
for basename in files:
fn = os.path.join(dir, basename)
relfn = os.path.relpath(fn, src)
ignore = False
if blacklist.match(relfn):
ignore = True
if whitelist.match(relfn):
ignore = False
if ignore:
rv.append(basename)
return rv
shutil.copytree(src, dest, ignore=ignore)
示例2: unpack_ant
def unpack_ant(interface):
if os.path.exists(plat.path("apache-ant")):
interface.success("Apache ANT has already been unpacked.")
return
archive = "apache-ant-1.8.4-bin.tar.gz"
unpacked = "apache-ant-1.8.4"
url = "http://archive.apache.org/dist/ant/binaries/" + archive
interface.info("I'm downloading Apache Ant. This might take a while.")
interface.download(url, plat.path(archive))
interface.info("I'm extracting Apache Ant.")
def extract():
tf = tarfile.open(plat.path(archive), "r:*")
tf.extractall(plat.path("."))
tf.close()
interface.background(extract)
plat.rename(plat.path(unpacked), plat.path("apache-ant"))
interface.success("I've finished unpacking Apache Ant.")
示例3: generate_keys
def generate_keys(interface):
set_property("key.alias", "android")
set_property("key.store.password", "android")
set_property("key.alias.password", "android")
default_keystore = plat.path("android.keystore").replace("\\", "/")
set_property("key.store", default_keystore)
if get_property("key.store") != default_keystore:
interface.info(__("You set the keystore yourself, so I'll assume it's how you want it."))
return
if os.path.exists(plat.path("android.keystore")):
interface.info(__("You've already created an Android keystore, so I won't create a new one for you."))
return
if not interface.yesno(__("I can create an application signing key for you. Signing an application with this key allows it to be placed in the Android Market and other app stores.\n\nDo you want to create a key?")):
return
if not interface.yesno(__("I will create the key in the android.keystore file.\n\nYou need to back this file up. If you lose it, you will not be able to upgrade your application.\n\n\You also need to keep the key safe. If evil people get this file, they could make fake versions of your application, and potentially steal your users' data.\n\nWill you make a backup of android.keystore, and keep it in a safe place?")):
return
org = interface.input(__("Please enter your name or the name of your organization."))
dname = "CN=" + org
if not run(interface, plat.keytool, "-genkey", "-keystore", "android.keystore", "-alias", "android", "-keyalg", "RSA", "-keysize", "2048", "-keypass", "android", "-storepass", "android", "-dname", dname, "-validity", "20000", use_path=True):
interface.fail(__("Could not create android.keystore. Is keytool in your path?"))
interface.success(__("I've finished creating android.keystore. Please back it up, and keep it in a safe place."))
示例4: make_expansion
def make_expansion():
zf = zipfile.ZipFile(plat.path(expansion_file), "w", zipfile.ZIP_STORED)
zip_directory(zf, "assets")
zf.close()
# Delete and re-make the assets directory.
shutil.rmtree(plat.path("assets"))
os.mkdir(plat.path("assets"))
示例5: extract
def extract():
if archive.endswith(".tgz"):
tf = tarfile.open(plat.path(archive), "r:*")
tf.extractall(plat.path("."))
tf.close()
else:
zf = zipfile.ZipFile(plat.path(archive))
zf.extractall(plat.path("."))
zf.close()
示例6: generate_keys
def generate_keys(interface):
# Change this method to allow for custom keystore passwords
update_properties = True
if os.path.exists(plat.path("local.properties")):
with open(plat.path("local.properties")) as f:
for l in f:
if l.startswith("key.store"):
update_properties = False
if update_properties:
f = file(plat.path("local.properties"), "a")
print >>f, "key.alias=android"
print >>f, "key.store.password=android"
print >>f, "key.alias.password=android"
print >>f, "key.store=android.keystore"
f.close()
if os.path.exists(plat.path("android.keystore")):
interface.info("You've already created an Android keystore, so I won't create a new one for you.")
return
if not interface.yesno("""\
I can create an application signing key for you. Signing an application with
this key allows it to be placed in the Android Market and other app stores.
Do you want to create a key?"""):
return
if not interface.yesno("""\
I will create the key in the android.keystore file.
You need to back this file up. If you lose it, you will not be able to upgrade
your application.
You also need to keep the key safe. If evil people get this file, they could
make fake versions of your application, and potentially steal your users'
data.
Will you make a backup of android.keystore, and keep it in a safe place?"""):
return
org = interface.input("Please enter your name or the name of your organization.")
dname = "CN=" + org
if not run(interface, plat.keytool, "-genkey", "-keystore", "android.keystore", "-alias", "android", "-keyalg", "RSA", "-keysize", "2048", "-keypass", "android", "-storepass", "android", "-dname", dname, "-validity", "20000", use_path=True):
interface.fail("Could not create android.keystore. Is keytool in your path?")
interface.success("""I've finished creating android.keystore. Please back it up, and keep it in a safe place.""")
示例7: unpack_sdk
def unpack_sdk(interface):
if os.path.exists(plat.path("android-sdk")):
interface.success("The Android SDK has already been unpacked.")
return
if "PGS4A_NO_TERMS" not in os.environ:
interface.terms("http://developer.android.com/sdk/terms.html", "Do you accept the Android SDK Terms and Conditions?")
if plat.windows:
archive = "android-sdk_{}-windows.zip".format(plat.sdk_version)
unpacked = "android-sdk-windows"
elif plat.macintosh:
archive = "android-sdk_{}-macosx.zip".format(plat.sdk_version)
unpacked = "android-sdk-macosx"
elif plat.linux:
archive = "android-sdk_{}-linux.tgz".format(plat.sdk_version)
unpacked = "android-sdk-linux"
url = "http://dl.google.com/android/" + archive
interface.info("I'm downloading the Android SDK. This might take a while.")
interface.download(url, plat.path(archive))
interface.info("I'm extracting the Android SDK.")
def extract():
if archive.endswith(".tgz"):
tf = tarfile.open(plat.path(archive), "r:*")
tf.extractall(plat.path("."))
tf.close()
else:
zf = zipfile.ZipFile(plat.path(archive))
# We have to do this because Python has a small (260?) path length
# limit on windows, and the Android SDK has a
old_cwd = os.getcwd()
os.chdir(plat.path("."))
zf.extractall(".")
os.chdir(old_cwd)
zf.close()
interface.background(extract)
plat.rename(plat.path(unpacked, replace=False), plat.path("android-sdk"))
interface.success("I've finished unpacking the Android SDK.")
示例8: install_sdk
def install_sdk(interface):
check_java(interface)
unpack_ant(interface)
unpack_sdk(interface)
if plat.macintosh or plat.linux:
os.chmod(plat.path("android-sdk/tools/android"), 0755)
os.chmod(plat.path("android-sdk/tools/zipalign"), 0755)
get_packages(interface)
generate_keys(interface)
interface.final_success("It looks like you're ready to start packaging games.")
示例9: copy_libs
def copy_libs():
"""
This copies updated libraries from the prototype to the project each
time a build occurs.
"""
for i in COPIED:
project = plat.path("project/" + i)
prototype = plat.path("prototype/" + i)
if os.path.exists(project):
shutil.rmtree(project)
shutil.copytree(prototype, project)
示例10: check_java
def check_java(interface):
"""
Checks for the presence of a minimally useful java on the user's system.
"""
interface.info(__("I'm compiling a short test program, to see if you have a working JDK on your system."))
if not run_slow(interface, plat.javac, plat.path("buildlib/CheckJDK8.java"), use_path=True):
interface.fail(__("I was unable to use javac to compile a test file. If you haven't installed the Java Development Kit yet, please download it from:\n\nhttp://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html\n\nThe JDK is different from the JRE, so it's possible you have Java without having the JDK. Without a working JDK, I can't continue."))
if not run_slow(interface, plat.java, "-classpath", plat.path("buildlib"), "CheckJDK8", use_path=True):
interface.fail(__("The version of Java on your computer does not appear to be JDK 8, which is the only version supported by the Android SDK. If you need to install JDK 8, you can download it from:\n\nhttp://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html\n\nYou can also set the JAVA_HOME environment variable to use a different version of Java."))
interface.success(__("The JDK is present and working. Good!"))
示例11: extract
def extract():
zf = FixedZipFile(plat.path(archive))
# We have to do this because Python has a small (260?) path length
# limit on windows, and the Android SDK has very long filenames.
old_cwd = os.getcwd()
os.chdir(plat.path("."))
zf.extractall("Sdk")
os.chdir(old_cwd)
zf.close()
示例12: distclean
def distclean(interface):
"""
Cleans everything back to as it was when RAPT was first distributed.
"""
if os.path.exists(plat.path("build_renpy.sh")):
raise Exception("Can't clean android directory!")
def rmdir(name):
path = plat.path(name)
if os.path.isdir(path):
shutil.rmtree(path)
def rm(name):
path = plat.path(name)
if os.path.exists(path):
os.unlink(path)
rm("buildlib/CheckJDK8.class")
rmdir("project")
rmdir("bin")
try:
rmdir("Sdk")
except:
rm("Sdk")
示例13: snarf
def snarf(fn):
fn = plat.path(fn)
if os.path.exists(fn):
return open(fn, "r").read().strip()
else:
return None
示例14: rmdir
def rmdir(name, make):
path = plat.path(name)
if os.path.isdir(path):
shutil.rmtree(path)
if make:
os.mkdir(path)
示例15: unpack_sdk
def unpack_sdk(interface):
if os.path.exists(plat.path("android-sdk")):
interface.success("The Android SDK has already been unpacked.")
return
if "PGS4A_NO_TERMS" not in os.environ:
interface.terms("http://developer.android.com/sdk/terms.html", "Do you accept the Android SDK Terms and Conditions?")
if plat.windows:
archive = "android-sdk_r20-windows.zip"
unpacked = "android-sdk-windows"
elif plat.macintosh:
archive = "android-sdk_r20-macosx.zip"
unpacked = "android-sdk-macosx"
elif plat.linux:
archive = "android-sdk_r20-linux.tgz"
unpacked = "android-sdk-linux"
url = "http://dl.google.com/android/" + archive
interface.info("I'm downloading the Android SDK. This might take a while.")
interface.download(url, plat.path(archive))
interface.info("I'm extracting the Android SDK.")
def extract():
if archive.endswith(".tgz"):
tf = tarfile.open(plat.path(archive), "r:*")
tf.extractall(plat.path("."))
tf.close()
else:
zf = zipfile.ZipFile(plat.path(archive))
zf.extractall(plat.path("."))
zf.close()
interface.background(extract)
plat.rename(plat.path(unpacked), plat.path("android-sdk"))
interface.success("I've finished unpacking the Android SDK.")