diff --git a/tools/otagui/README.md b/tools/otagui/README.md index c4c57c289..f4ec98729 100644 --- a/tools/otagui/README.md +++ b/tools/otagui/README.md @@ -15,6 +15,13 @@ In this case we use `lunch 17` as an example (aosp-x86_64-cf), you can choose wh Then, in this directory, please use `npm build` to install the dependencies. +Create a `target` directory to store the target files and a `output` directory +to store the output files: +``` +mkdir target +mkdir output +``` + Finally, run the python http-server and vue.js server: ``` python3 web_server.py & diff --git a/tools/otagui/ota_interface.py b/tools/otagui/ota_interface.py new file mode 100644 index 000000000..387ddddbf --- /dev/null +++ b/tools/otagui/ota_interface.py @@ -0,0 +1,86 @@ +import subprocess +import os +import json +import pipes +from threading import Lock +import logging + +class ProcessesManagement: + def __init__(self): + self.__container = {} + self.__lock = Lock() + + def set(self, name, value): + with self.__lock: + self.__container[name] = value + + def get(self, name): + with self.__lock: + return self.__container[name] + + def get_keys(self): + with self.__lock: + return self.__container.keys() + + def get_status_by_ID(self, id=0, details=False): + status = {} + if not id in self.get_keys(): + return '{}' + else: + status['id'] = id + if self.get(id).poll() == None: + status['status'] = 'Running' + elif self.get(id).poll() == 0: + status['status'] = 'Finished' + status['path'] = os.path.join('output', str(id) + '.zip') + else: + status['status'] = 'Error' + try: + if details: + with open(os.path.join('output', 'stdout.' + str(id)), 'r') as fout: + status['stdout'] = fout.read() + with open(os.path.join('output', 'stderr.' + str(id)), 'r') as ferr: + status['stderr'] = ferr.read() + except FileNotFoundError: + status['stdout'] = 'NO STD OUTPUT IS FOUND' + status['stderr'] = 'NO STD OUTPUT IS FOUND' + return status + + def get_status(self): + return [self.get_status_by_ID(id=id) for id in self.get_keys()] + + def get_list(self, dir): + files = os.listdir(dir) + return files + + def ota_generate(self, args, id=0): + command = ['ota_from_target_files'] + # Check essential configuration is properly set + if not os.path.isfile('target/' + args['target']): + raise FileNotFoundError + if not args['output']: + raise SyntaxError + if args['verbose']: + command.append('-v') + command.append('-k') + command.append( + '../../../build/make/target/product/security/testkey') + if args['incremental']: + if not os.path.isfile('target/' + args['incremental']): + raise FileNotFoundError + command.append('-i') + command.append('target/' + args['incremental']) + command.append('target/' + args['target']) + command.append(args['output']) + + stderr_pipes = pipes.Template() + stdout_pipes = pipes.Template() + ferr = stderr_pipes.open(os.path.join( + 'output', 'stderr.'+str(id)), 'w') + fout = stdout_pipes.open(os.path.join( + 'output', 'stdout.'+str(id)), 'w') + self.set(id, subprocess.Popen( + command, stderr=ferr, stdout=fout)) + logging.info( + 'Starting generating OTA package with id {}: \n {}' + .format(id, command)) \ No newline at end of file diff --git a/tools/otagui/package-lock.json b/tools/otagui/package-lock.json index 10dfdb259..cd4c13915 100644 --- a/tools/otagui/package-lock.json +++ b/tools/otagui/package-lock.json @@ -12,6 +12,7 @@ "eslint-config-airbnb-base": "^14.2.1", "vue": "^3.0.0-0", "vue-router": "^4.0.0-0", + "vue-uuid": "^2.0.2", "vuex": "^4.0.0-0" }, "devDependencies": { @@ -1479,6 +1480,11 @@ "source-map": "^0.6.1" } }, + "node_modules/@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==" + }, "node_modules/@types/webpack": { "version": "4.41.21", "resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-4.41.21.tgz", @@ -13339,6 +13345,23 @@ "integrity": "sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==", "dev": true }, + "node_modules/vue-uuid": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/vue-uuid/-/vue-uuid-2.0.2.tgz", + "integrity": "sha512-PRf1CHg3uKi77bVRyAuW2u/T2PO9LxMr7cw9t9rNdpZTkNDyw1Fx6eJVL+8JOtM9VxxPkoZ/rwhXJ5l+X5AYzQ==", + "dependencies": { + "@types/uuid": "^8.0.0", + "uuid": "^8.1.0" + } + }, + "node_modules/vue-uuid/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/vuex": { "version": "4.0.0-beta.4", "resolved": "https://registry.npmjs.org/vuex/-/vuex-4.0.0-beta.4.tgz", @@ -15792,6 +15815,11 @@ "source-map": "^0.6.1" } }, + "@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==" + }, "@types/webpack": { "version": "4.41.21", "resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-4.41.21.tgz", @@ -25710,6 +25738,22 @@ "integrity": "sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==", "dev": true }, + "vue-uuid": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/vue-uuid/-/vue-uuid-2.0.2.tgz", + "integrity": "sha512-PRf1CHg3uKi77bVRyAuW2u/T2PO9LxMr7cw9t9rNdpZTkNDyw1Fx6eJVL+8JOtM9VxxPkoZ/rwhXJ5l+X5AYzQ==", + "requires": { + "@types/uuid": "^8.0.0", + "uuid": "^8.1.0" + }, + "dependencies": { + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + } + } + }, "vuex": { "version": "4.0.0-beta.4", "resolved": "https://registry.npmjs.org/vuex/-/vuex-4.0.0-beta.4.tgz", diff --git a/tools/otagui/package.json b/tools/otagui/package.json index dddbc2a58..f8596a752 100644 --- a/tools/otagui/package.json +++ b/tools/otagui/package.json @@ -12,6 +12,7 @@ "eslint-config-airbnb-base": "^14.2.1", "vue": "^3.0.0-0", "vue-router": "^4.0.0-0", + "vue-uuid": "^2.0.2", "vuex": "^4.0.0-0" }, "devDependencies": { diff --git a/tools/otagui/src/components/BaseFile.vue b/tools/otagui/src/components/BaseFile.vue index 82150dec8..dd072fbf4 100644 --- a/tools/otagui/src/components/BaseFile.vue +++ b/tools/otagui/src/components/BaseFile.vue @@ -1,7 +1,7 @@