def do_export(self, args):
        try:
            #add arguments
            doParser = self.arg_export()
            try:
                doArgs = doParser.parse_args(args.split())
            except SystemExit as e:
                return
                #call UForge API
            printer.out("Exporting template with id ["+doArgs.id+"] :")
            myAppliance = self.api.Users(self.login).Appliances(doArgs.id).Get()
            if myAppliance is None or type(myAppliance) is not Appliance:
                printer.out("No template")
            else:
                applianceExport = self.api.Users(self.login).Appliances(myAppliance.dbId).Exports().Export()
                status = applianceExport.status
                progress = ProgressBar(widgets=[Percentage(), Bar()], maxval=100).start()
                while not (status.complete or status.error):
                    progress.update(status.percentage)
                    status = self.api.Users(self.login).Appliances(myAppliance.dbId).Exports(applianceExport.dbId).Status.Get()
                    time.sleep(2)
                progress.finish()
                if status.error:
                    printer.out("Export error: "+status.message+"\n"+status.errorMessage, printer.ERROR)
                    if status.detailedError:
                        printer.out(status.detailedErrorMsg)
                else:
                    printer.out("Downloading archive...")
                    data = self.api.Users(self.login).Appliances(myAppliance.dbId).Exports(applianceExport.dbId).Downloads.Download()
                    if doArgs.file is None:
                        file = open("archive.tar.gz", "w")
                    else:
                        file = open(doArgs.file, "w")
                    file.write(data)
                    file.close()

                    #Delete export archive on the server
                    self.api.Users(self.login).Appliances(myAppliance.dbId).Exports(applianceExport.dbId).Delete()

                    printer.out("Download complete of file ["+file.name+"]", printer.OK)
            return 0
        except __HOLE__ as e:
            printer.out("File error: "+str(e), printer.ERROR)
        except ArgumentParserError as e:
            printer.out("ERROR: In Arguments: "+str(e), printer.ERROR)
            self.help_export()
        except Exception as e:
            return handle_uforge_exception(e)
dataset/ETHPy150Open usharesoft/hammr/src/hammr/commands/template/template.py/Template.do_export