Commit 72533e6e authored by Anze Vavpetic's avatar Anze Vavpetic
Browse files

added support for exporting external packages to a custom folder

parent 76cb82f4
...@@ -71,13 +71,18 @@ def serialize_category(c): ...@@ -71,13 +71,18 @@ def serialize_category(c):
data['fields'].pop('user') data['fields'].pop('user')
return data return data
def export_package(package_name,writer): def export_package(package_name,writer,dest_folder=None):
style = color_style() style = color_style()
external = package_name in settings.INSTALLED_APPS_EXTERNAL_PACKAGES
if external and not dest_folder:
raise CommandError("You must provide a destination folder when exporting external packages.")
if package_name in settings.INSTALLED_APPS_EXTERNAL_PACKAGES: if not external and dest_folder:
raise CommandError("You cannot export external packages.") raise CommandError("You can't use a custom destination folder when exporting local packages.")
if 'workflows.'+package_name not in settings.INSTALLED_APPS: if 'workflows.'+package_name not in settings.INSTALLED_APPS and not external:
raise CommandError("Package not found in INSTALLED_APPS.") raise CommandError("Package not found in INSTALLED_APPS.")
#here we check the integrity of the package #here we check the integrity of the package
...@@ -92,7 +97,10 @@ def export_package(package_name,writer): ...@@ -92,7 +97,10 @@ def export_package(package_name,writer):
#first we check if package_data directory exists and make it if it doesn't #first we check if package_data directory exists and make it if it doesn't
package_directory = os.path.join(os.path.dirname(os.path.realpath(__file__)),'../../'+package_name+"/package_data/") if external:
package_directory = dest_folder
else:
package_directory = os.path.join(os.path.dirname(os.path.realpath(__file__)),'../../'+package_name+"/package_data/")
ensure_dir(package_directory) ensure_dir(package_directory)
widgets_directory = os.path.join(package_directory,"widgets") widgets_directory = os.path.join(package_directory,"widgets")
deprecated_widgets_directory = os.path.join(package_directory,"deprecated_widgets") deprecated_widgets_directory = os.path.join(package_directory,"deprecated_widgets")
...@@ -182,15 +190,19 @@ def export_package(package_name,writer): ...@@ -182,15 +190,19 @@ def export_package(package_name,writer):
class Command(BaseCommand): class Command(BaseCommand):
args = 'package_name' args = 'package_name [external_destination_folder]'
help = 'Exports the package "package_name".' help = 'Exports the package "package_name".'
def handle(self, *args, **options): def handle(self, *args, **options):
if (len(args) < 1): if len(args) < 1:
raise CommandError('Argument "package_name" is required.') raise CommandError('Argument "package_name" is required.')
dest_folder = None
if len(args) == 2:
dest_folder = args[1]
package_name = args[0] package_name = args[0]
writer = self.stdout writer = self.stdout
export_package(package_name,writer) export_package(package_name,writer,dest_folder=dest_folder)
writer.write('Thanks for using the new export command. You rock.\n') writer.write('Thanks for using the new export command. You rock.\n')
\ No newline at end of file
...@@ -22,7 +22,6 @@ class Command(BaseCommand): ...@@ -22,7 +22,6 @@ class Command(BaseCommand):
package_name = app.split('workflows.')[1] package_name = app.split('workflows.')[1]
packages.append(package_name) packages.append(package_name)
elif app in settings.INSTALLED_APPS_EXTERNAL_PACKAGES: elif app in settings.INSTALLED_APPS_EXTERNAL_PACKAGES:
print app
extern_packages.append(app) extern_packages.append(app)
for package in packages: for package in packages:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment