Ejemplo n.º 1
0
	def build_xpi_test(self, modules):
		" prepare and build XPI for test only (unsaved modules) "
		if self.package.type == 'l':
			raise Exception('only Add-ons may build a XPI')

		sdk_dir = self.get_sdk_dir()
		# TODO: consider SDK staying per PackageRevision...
		if os.path.isdir(sdk_dir):
			xpi_remove(sdk_dir)
		sdk_copy(sdk_dir)
		self.export_keys(sdk_dir)

		packages_dir = '%s/packages' % sdk_dir
		package_dir = self.package.make_dir(packages_dir)
		self.export_manifest(package_dir)
		# instead of export modules
		lib_dir = '%s/%s' % (package_dir, self.package.get_lib_dir())
		for mod in self.modules.all():
			mod_edited = False
			for e_mod in modules:
				if e_mod.pk == mod.pk:
					mod_edited = True
					e_mod.export_code(lib_dir)
			if not mod_edited:
				mod.export_code(lib_dir)
		self.export_attachments('%s/%s' % (package_dir, self.package.get_data_dir()))
		self.export_dependencies(packages_dir)
		return (xpi_build(sdk_dir, 
				'%s/packages/%s' % (sdk_dir, self.package.get_unique_package_name()))
				)
Ejemplo n.º 2
0
def remove_xpi(r, sdk_name):
    " remove whole temporary SDK on request "
    # Validate sdk_name
    if not validator.is_valid("alphanum_plus", sdk_name):
        return HttpResponseForbidden("{'error': 'Wrong name'}")
    xpi_remove("%s-%s" % (settings.SDKDIR_PREFIX, sdk_name))
    return HttpResponse("{}", mimetype="application/json")
Ejemplo n.º 3
0
    def build_xpi_test(self, modules):
        " prepare and build XPI for test only (unsaved modules) "
        if self.package.type == "l":
            raise Exception("only Add-ons may build a XPI")

        sdk_dir = self.get_sdk_dir()
        sdk_source = self.sdk.get_source_dir()
        # This SDK is always different! - working on unsaved data
        if os.path.isdir(sdk_dir):
            xpi_remove(sdk_dir)
        sdk_copy(sdk_source, sdk_dir)
        self.export_keys(sdk_dir)

        packages_dir = "%s/packages" % sdk_dir
        package_dir = self.package.make_dir(packages_dir)
        self.export_manifest(package_dir)
        # instead of export modules
        lib_dir = "%s/%s" % (package_dir, self.package.get_lib_dir())
        for mod in self.modules.all():
            mod_edited = False
            for e_mod in modules:
                if e_mod.pk == mod.pk:
                    mod_edited = True
                    e_mod.export_code(lib_dir)
            if not mod_edited:
                mod.export_code(lib_dir)
        self.export_attachments("%s/%s" % (package_dir, self.package.get_data_dir()))
        self.export_dependencies(packages_dir)
        return xpi_build(sdk_dir, "%s/packages/%s" % (sdk_dir, self.package.get_unique_package_name()))
Ejemplo n.º 4
0
	def build_xpi(self):
		" prepare and build XPI "
		if self.package.type == 'l':
			raise Exception('only Add-ons may build a XPI')

		sdk_dir = self.get_sdk_dir()
		# TODO: consider SDK staying per PackageRevision...
		if os.path.isdir(sdk_dir):
			xpi_remove(sdk_dir)
		sdk_copy(sdk_dir)
		self.export_keys(sdk_dir)
		self.export_files_with_dependencies('%s/packages' % sdk_dir)
		return (xpi_build(sdk_dir, 
				'%s/packages/%s' % (sdk_dir, self.package.get_unique_package_name()))
				)
Ejemplo n.º 5
0
def package_download_xpi(r, id_number, revision_number=None):
    """
    Edit package - only for the author
    """
    revision = get_object_with_related_or_404(
        PackageRevision, package__id_number=id_number, package__type="a", revision_number=revision_number
    )

    (stdout, stderr) = revision.build_xpi()

    if stderr and not settings.DEBUG:
        # XXX: this should also log the error in file
        xpi_remove(revision.get_sdk_dir())

    return download_xpi(r, revision.get_sdk_name(), revision.package.get_unique_package_name(), revision.package.name)
Ejemplo n.º 6
0
def package_test_xpi(r, id_number, revision_number=None):
    """
    Test XPI from data saved in the database
    """
    revision = get_object_with_related_or_404(
        PackageRevision, package__id_number=id_number, package__type="a", revision_number=revision_number
    )

    # support temporary data
    if r.POST.get("live_data_testing", False):
        modules = []
        for mod in revision.modules.all():
            if r.POST.get(mod.filename, False):
                code = r.POST.get(mod.filename, "")
                if mod.code != code:
                    mod.code = code
                    modules.append(mod)
        (stdout, stderr) = revision.build_xpi_test(modules)

    else:
        (stdout, stderr) = revision.build_xpi()

    if stderr and not settings.DEBUG:
        # XXX: this should also log the error in file
        xpi_remove(revision.get_sdk_dir())

    # return XPI url and cfx command stdout and stderr
    return render_to_response(
        "json/test_xpi_created.json",
        {
            "stdout": stdout,
            "stderr": stderr,
            "test_xpi_url": reverse(
                "jp_test_xpi",
                args=[revision.get_sdk_name(), revision.package.get_unique_package_name(), revision.package.name],
            ),
            "download_xpi_url": reverse(
                "jp_download_xpi",
                args=[revision.get_sdk_name(), revision.package.get_unique_package_name(), revision.package.name],
            ),
            "rm_xpi_url": reverse("jp_rm_xpi", args=[revision.get_sdk_name()]),
            "addon_name": '"%s (%s)"' % (revision.package.full_name, revision.get_version_name()),
        },
        context_instance=RequestContext(r),
    )
Ejemplo n.º 7
0
def package_test_xpi(r, id, revision_number=None, version_name=None):
	"""
	Test XPI from data saved in the database
	"""
	revision = get_object_with_related_or_404(PackageRevision, 
						package__id_number=id, package__type='a',
						revision_number=revision_number)

	
	# support temporary data
	if r.POST.get('live_data_testing', False):
		modules = []
		for mod in revision.modules.all():
			if r.POST.get(mod.filename, False):
				code = r.POST[mod.filename]
				if mod.code != code:
					mod.code = code
					modules.append(mod)
		(stdout, stderr) = revision.build_xpi_test(modules)

	else:
		(stdout, stderr) = revision.build_xpi()

	if stderr and not settings.DEBUG:
		xpi_remove(sdk_dir)

	# return XPI url and cfx command stdout and stderr
 	return render_to_response('json/test_xpi_created.json', {
 					'stdout': stdout,
					'stderr': stderr,
 					'test_xpi_url': reverse('jp_test_xpi', 
									args=[
										revision.get_sdk_name(), 
										revision.package.get_unique_package_name(), 
										revision.package.name
										]), 
 					'download_xpi_url': reverse('jp_download_xpi', 
									args=[
										revision.get_sdk_name(), 
										revision.package.get_unique_package_name(), 
										revision.package.name
										]), 
 					'rm_xpi_url': reverse('jp_rm_xpi', args=[revision.get_sdk_name()])
 				},
				context_instance=RequestContext(r))
Ejemplo n.º 8
0
    def build_xpi(self):
        " prepare and build XPI "
        if self.package.type == "l":
            raise Exception("only Add-ons may build a XPI")
        if not self.sdk:
            raise Exception("only Add-ons with assigned SDK may build XPI")

        sdk_dir = self.get_sdk_dir()
        sdk_source = self.sdk.get_source_dir()

        # TODO: consider SDK staying per PackageRevision...
        if os.path.isdir(sdk_dir):
            xpi_remove(sdk_dir)

        sdk_copy(sdk_source, sdk_dir)
        self.export_keys(sdk_dir)
        self.export_files_with_dependencies("%s/packages" % sdk_dir)
        return xpi_build(sdk_dir, "%s/packages/%s" % (sdk_dir, self.package.get_unique_package_name()))
Ejemplo n.º 9
0
def package_download_xpi(r, id, revision_number=None, version_name=None):
	"""
	Edit package - only for the author
	"""
	revision = get_object_with_related_or_404(PackageRevision, 
						package__id_number=id, package__type='a',
						revision_number=revision_number)

	(stdout, stderr) = revision.build_xpi()

	if stderr and not settings.DEBUG:
		xpi_remove(sdk_dir)

	return download_xpi(r, 
					revision.get_sdk_name(), 
					revision.package.get_unique_package_name(), 
					revision.package.name
					)
Ejemplo n.º 10
0
def remove_xpi(r, sdk_name):
	xpi_remove('%s-%s' % (settings.SDKDIR_PREFIX, sdk_name))
	return HttpResponse('{}', mimetype='application/json')