[r55]: / trunk / cforge / cforge / Package / CFORGE / Scripts / build.py  Maximize  Restore  History

Download this file

55 lines (42 with data), 1.7 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import sys, os
import zipfile
import cds_script


# This is a cforge command (script file)
# this will be run as ironpython script.
# the filename of this script is automatically the corresponding cforge command 
# with some magic functions you can easily integrate it nicely into cforge tool

# cforge_usage: 
# here you can return an array of all possible arguments and options that can 
# be passed to this command script
def cforge_usage():
    help = [ 
        ["<path to local repository>", "---"]
    ]

    return help


if len(sys.argv) <= 1:
    print("Oh, there are no arguments. Perhaps you forgot something?")
    sys.exit()

folder = sys.argv[1]
scriptpath = os.path.abspath(os.path.dirname(sys.argv[0]))

def zipdir(path, ziph):
    # ziph is zipfile handle
    for root, dirs, files in os.walk(path):
        for file in files:
            filename=os.path.join(root, file)
            archname=filename[len(path)+1:]
            print("Adding file: %s -> %s" % (filename, archname))
            ziph.write(filename, arcname=archname)


# Build all packages
for root, dirs, files in os.walk(folder):
    for file in files:
        if file == "package.manifest":
            packageDir = root
            packageName = root + ".package"
            print("Creating package: '%s' -> '%s'" % (packageDir, packageName))
            zipf = zipfile.ZipFile(packageName, 'w', zipfile.ZIP_DEFLATED)
            zipdir(packageDir, zipf)
            zipf.close()

# Export documentation as markdown

scriptname = os.path.join(scriptpath, "action.markdown.py")
scriptargs = folder

cds_script.RunCodesysWithScript(scriptname, scriptargs, False)