Hi ! I have create a small python application for create LMMS projects package :
→ List all files from project
→ Compact all imported files into ZIP file (in data directory)
→ Update all import directory from projects
Usage : lmmspackager.py project.mmp [projectoutput.zip]
For get code, copy/paste all content into .py file.
Tested under GNU/Linux system. Can you test on Windows computer ?
File can be download here : http://82.235.150.75:4080/share/Ff_Nv1J ... spackager/
Tested with SF2 and external audio files.
→ List all files from project
→ Compact all imported files into ZIP file (in data directory)
→ Update all import directory from projects
Usage : lmmspackager.py project.mmp [projectoutput.zip]
Code: Select all
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import xml.etree.ElementTree as ET
import os
import zipfile
import sys
print("""LazyOne Software LMMS Project Packager
Code is under GPLV3 license. \n\n""")
if len(sys.argv) < 2:
print("""
USAGE : %s <project File Name (mmp file)> <output zip file>
""" % sys.argv[0])
sys.exit(1)
filein = sys.argv[1]
if len(sys.argv) < 3:
fileout = os.path.basename("".join(filein.split(".")[:-1])) + ".zip"
else:
fileout = sys.argv[2]
if not os.path.isfile(filein):
print("File not found : %s" % (filein))
sys.exit(2)
zipout = zipfile.ZipFile(fileout, "w")
print("Packaging LMMS Project. Please wait ...\n")
print("[INFO] Opening project source ...")
filehandler = open(filein, "r")
dataread = "".join(filehandler.readlines())
filehandler.close()
tree = ET.fromstring(dataread)
#root = tree.getroot()
compressed = list()
notfound = 0
for e in tree.findall(".//*"):
if "src" in e.attrib.keys():
fromfile = e.attrib["src"]
basename = os.path.basename(fromfile)
if not basename in compressed:
print("[INFO] Packaging : %s" % (fromfile))
if not os.path.isfile(fromfile):
print("ERROR : %s not found. Project Packager continue to try to ZIP other files into .zip")
notfound =+ 1
else:
zipout.write(fromfile, "data/%s" % (basename))
compressed.append(basename)
e.set("src", "./data/%s" % (basename))
print("[INFO] Packaging updated project file ...")
zipout.writestr(os.path.basename(filein), ET.tostring(tree))
zipout.close()
print("[INFO] DONE.")
print("\n\nYour project has been packaged into %s !" % (fileout))
if notfound > 0:
print("Therefore, %s file(s) has not packaged.")
Tested under GNU/Linux system. Can you test on Windows computer ?
File can be download here : http://82.235.150.75:4080/share/Ff_Nv1J ... spackager/
Tested with SF2 and external audio files.