Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import re
- import datetime as dt
- import time
- MANIFEST_PATH = 'app/META-INF/MANIFEST.MF'
- DEVICEINFO_PATH = '/pps/services/deviceproperties'
- BUILDINFO_PATH = 'app/native/build.info'
- class AppUtil:
- # default values
- date = '2012-01-01'
- title = 'ThisApp'
- author = 'Author'
- app_version = '0.0'
- os_version = '10.0'
- def __init__(self):
- try:
- with open(MANIFEST_PATH) as manifest:
- text = manifest.read(2000)
- for pat, name in [
- (r'Application-Version: (.+)', 'app_version'),
- (r'Application-Name: (.+)', 'title'),
- (r'Package-Author: (.+)', 'author'),
- ]:
- match = re.search(pat, text)
- if match:
- setattr(self, name, match.group(1))
- # print(name, getattr(self, name))
- except IOError:
- pass
- try:
- with open(DEVICEINFO_PATH) as devinfo:
- text = devinfo.read()
- for pat, name in [
- (r'scmbundle::(.+)', 'os_version'),
- ]:
- match = re.search(pat, text)
- if match:
- setattr(self, name, match.group(1))
- # print(name, getattr(self, name))
- except IOError:
- pass
- try:
- with open(BUILDINFO_PATH) as buildinfo:
- text = buildinfo.read().strip()
- build_time = dt.datetime.strptime(text, '%Y-%m-%d %H:%M:%S.%f')
- self.date = str(build_time.date())
- self.build_time = str(build_time)
- except IOError:
- pass
- metadata = AppUtil()
- # EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement