def github_download(self, url, dir_name, blacklist=None): if not blacklist: blacklist = [] if not path.exists(dir_name): makedirs(dir_name) github_dir = json.loads(get_url_retry(url)) for item in github_dir: if item['type'] == 'file' and item['name'] not in blacklist: info('Downloading: {0}'.format(item['name'])) raw_data = get_url_retry(item['url']) with open(path.join(dir_name, item['name']), 'w') as export: decoded_data = base64.b64decode(json.loads(raw_data)['content']) export.write(decoded_data) elif item['type'] == 'dir': self.github_download(item['url'], path.join(dir_name, item['name']))
def update(self, version): self.init() info('Retrieving robot core...') zip_stream = StringIO.StringIO(get_url_retry(ROBOT_CORE_URL)) robot_core = zipfile.ZipFile(zip_stream).open('classes.jar').read() info('Saving robot core...') with open(path.join(self.dir, 'robotcore-latest.jar'), 'wb') as jar: jar.write(robot_core) info('Robot-core Saved!') info('Maven-izing project...') status, _ = commands.getstatusoutput( MAVEN_ADD_CMD.format(version, path.join(self.dir, 'robotcore-latest.jar'), path.join(self.dir, 'repo'))) if status != 0: error('Maven is not installed!' if status == 32512 else 'Maven failed to install dependency') info('Maven sync complete!') self.mavenPlugin.reset() info('Maven-izing plugin...') status, _ = commands.getstatusoutput(MAVEN_INSTALL_CMD.format(self.mavenPlugin.dir, path.join(self.dir, 'repo'))) if status != 0: error('Maven is not installed!' if status == 32512 else 'Maven failed to install dependency') info('Maven sync complete!') info('Writing readme...') with open('resources/robotcore-template.md', 'r') as template: with open(path.join(self.dir, 'README.md'), 'wb') as readme: readme.write(template.read().format(version)) info('Wrote readme!')