def try_reload(self): mtime = os.stat(path.blacklist_file)[stat.ST_MTIME] if mtime != self.blacklist_file_mtime: log.notice("blacklist file has changed, reloading...") self.reload() return True return False
def run(): import sys try: _opts = options.load(args = sys.argv, logfile = False) log.notice('RTEMS Source Builder - Check, %s' % (version.str())) orphans = _opts.parse_args('--check-orphans', error = False, extra = False) if orphans: print('Checking for orphans...') check_orphans(_opts) else: if host_setup(_opts): print('Environment is ok') else: print('Environment is not correctly set up') except error.general as gerr: print(gerr) sys.exit(1) except error.internal as ierr: print(ierr) sys.exit(1) except error.exit as eerr: pass except KeyboardInterrupt: log.notice('abort: user terminated') sys.exit(1) sys.exit(0)
def loadHandler(self, human, values): mhclo = values[1] if not os.path.exists(os.path.realpath(mhclo)): log.notice('HairTaskView.loadHandler: %s does not exist. Skipping.', mhclo) return self.setHair(human, mhclo)
def run(): import sys try: # # Run where defaults.mc is located # long_opts = { # key macro handler param defs init '--file': ('_file', 'path', True, None, False) } opts = options.command_line(base_path='.', argv=sys.argv, long_opts=long_opts) options.load(opts) s = file(opts.defaults['_file'], opts) s.load(opts.defaults['_file']) print(s) del s except error.general as gerr: print(gerr) sys.exit(1) except error.internal as ierr: print(ierr) sys.exit(1) except KeyboardInterrupt: log.notice('abort: user terminated') sys.exit(1) sys.exit(0)
def getSelectedBone(self): for (name,button) in self.boneButtons.items(): if button.selected: #print "Bone", name, "selected" return self.armature.bones[name] log.notice("BUG: No bone selected") return None
def generate(name, opts, header=None, footer=None): label, result = opts.with_arg('error-report') if (label.startswith('without_') and result != 'yes') or \ (label.startswith('with_') and result != 'no'): r = ['RTEMS Tools Project - Source Builder Error Report'] + [] if header: r += [' %s' % (header)] r += [opts.info()] if opts.defaults.get_value('%{_sbgit_valid}') == '1': r += [ ' %s/%s' % (opts.defaults.get_value('%{_sbgit_remotes}'), opts.defaults.get_value('%{_sbgit_id}')) ] else: r += [' RSB: not a valid repo'] if os.name == 'nt': r += [' Windows'] else: r += [' %s' % (' '.join(os.uname()))] r += [] r += ['Tail of the build log:'] r += log.tail() if footer: r += [footer] try: name = name.replace('/', '-') with open(name, 'w') as l: l.write(os.linesep.join(r)) log.notice(' See error report: %s' % (name)) except: log.stderr('error: failure to create error report') raise
def get_file(url, local, opts, config): if local is None: raise error.general("source/patch path invalid") if not path.isdir(path.dirname(local)) and not opts.download_disabled(): log.notice("Creating source directory: %s" % (os.path.relpath(path.host(path.dirname(local))))) log.output("making dir: %s" % (path.host(path.dirname(local)))) if not opts.dry_run(): path.mkdir(path.dirname(local)) if not path.exists(local) and opts.download_disabled(): raise error.general("source not found: %s" % (path.host(local))) # # Check if a URL has been provided on the command line. # url_bases = opts.urls() urls = [] if url_bases is not None: for base in url_bases: if base[-1:] != "/": base += "/" url_path = urlparse.urlsplit(url)[2] slash = url_path.rfind("/") if slash < 0: url_file = url_path else: url_file = url_path[slash + 1 :] urls.append(urlparse.urljoin(base, url_file)) urls += url.split() log.trace("_url: %s -> %s" % (",".join(urls), local)) for url in urls: for dl in downloaders: if url.startswith(dl): if downloaders[dl](url, local, config, opts): return if not opts.dry_run(): raise error.general("downloading %s: all paths have failed, giving up" % (url))
def __init__(self, category): gui3d.TaskView.__init__(self, category, 'Material Editor') self.human = gui3d.app.selectedHuman self.humanObjSelector = self.addLeftWidget(HumanObjectSelector(self.human)) @self.humanObjSelector.mhEvent def onActivate(value): self.reloadMaterial() shaderBox = self.addLeftWidget(gui.GroupBox('Shader')) self.shaderList = shaderBox.addWidget(gui.ListView()) self.shaderList.setSizePolicy(gui.SizePolicy.Ignored, gui.SizePolicy.Preferred) self.shaderConfBox = self.addLeftWidget(gui.GroupBox('Shader config')) shaderConfig = self.human.material.shaderConfig for name in shaderConfig: chkBox = gui.CheckBox(name, shaderConfig[name]) self.shaderConfBox.addWidget(chkBox) @chkBox.mhEvent def onClicked(event): shaderConfig = dict() for child in self.shaderConfBox.children: shaderConfig[str(child.text())] = child.isChecked() self.getSelectedObject().material.configureShading(**shaderConfig) self.shaderDefBox = self.addLeftWidget(gui.GroupBox('Custom shader defines')) self.paramBox = self.addRightWidget(gui.GroupBox('Shader parameters')) self.materialBox = self.addRightWidget(gui.GroupBox('Material settings')) if not shader.Shader.supported(): log.notice('Shaders not supported') self.shaderList.setEnabled(False) self.shaderList.hide() self.paramBox.hide() @self.shaderList.mhEvent def onClicked(item): self.setShader(unicode(item.getUserData())) self.loadSaveBox = self.addRightWidget(gui.GroupBox("Material file")) self.loadMaterialBtn = self.loadSaveBox.addWidget(gui.BrowseButton(), 0, 0) self.loadMaterialBtn.setFilter("MakeHuman Material (*.mhmat)") self.loadMaterialBtn.setText('Load') @self.loadMaterialBtn.mhEvent def onClicked(path): if path: self.loadMaterial(path) self.saveMaterialBtn = self.loadSaveBox.addWidget(gui.BrowseButton('save'), 0, 1) self.saveMaterialBtn.setFilter("MakeHuman Material (*.mhmat)") self.saveMaterialBtn.setText('Save') @self.saveMaterialBtn.mhEvent def onClicked(path): if path: if not os.path.splitext(path)[1]: path = path + ".mhmat" self.saveMaterial(path)
def run(): import sys ec = 0 setbuilder_error = False try: optargs = { '--list-configs': 'List available configurations', '--list-bsets': 'List available build sets', '--list-deps': 'List the dependent files.', '--bset-tar-file': 'Create a build set tar file', '--pkg-tar-files': 'Create package tar files', '--no-report': 'Do not create a package report.', '--report-format': 'The report format (text, html, asciidoc).' } mailer.append_options(optargs) opts = options.load(sys.argv, optargs) log.notice('RTEMS Source Builder - Set Builder, %s' % (version.str())) opts.log_info() if not check.host_setup(opts): raise error.general('host build environment is not set up correctly') configs = build.get_configs(opts) if opts.get_arg('--list-deps'): deps = [] else: deps = None if not list_bset_cfg_files(opts, configs): prefix = opts.defaults.expand('%{_prefix}') if opts.canadian_cross(): opts.disable_install() if not opts.dry_run() and \ not opts.canadian_cross() and \ not opts.no_install() and \ not path.ispathwritable(prefix): raise error.general('prefix is not writable: %s' % (path.host(prefix))) for bset in opts.params(): setbuilder_error = True b = buildset(bset, configs, opts) b.build(deps) b = None setbuilder_error = False if deps is not None: c = 0 for d in sorted(set(deps)): c += 1 print('dep[%d]: %s' % (c, d)) except error.general as gerr: if not setbuilder_error: log.stderr(str(gerr)) log.stderr('Build FAILED') ec = 1 except error.internal as ierr: if not setbuilder_error: log.stderr(str(ierr)) log.stderr('Internal Build FAILED') ec = 1 except error.exit as eerr: pass except KeyboardInterrupt: log.notice('abort: user terminated') ec = 1 sys.exit(ec)
def make(self): package = self.main_package() if package.disabled(): log.notice('package: nothing to build') else: name = package.name() if self.canadian_cross(): log.notice('package: (Cxc) %s' % (name)) else: log.notice('package: %s' % (name)) log.trace('---- macro maps %s' % ('-' * 55)) log.trace('%s' % (str(self.config.macros))) log.trace('-' * 70) self.script.reset() self.script.append(self.config.expand('%{___build_template}')) self.script.append('echo "=> ' + name + ':"') self.prep(package) self.build_package(package) if not self.opts.dry_run(): self.builddir() sn = path.join(self.config.expand('%{_builddir}'), 'doit') log.output('write script: ' + sn) self.script.write(sn) if self.canadian_cross(): log.notice('building: (Cxc) %s' % (name)) else: log.notice('building: %s' % (name)) self.run(sn)
def try_reload(self): mtime = os.stat(path.acl_conf)[stat.ST_MTIME] if mtime != self.acl_conf_mtime: log.notice("acl.conf has changed, reloading...") self.reload() return True return False
def download(self, url): filename = os.path.basename(url) if os.path.exists(os.path.join(self.path, filename)): etag, modified = self.cache.get(filename, (None, None)) else: etag, modified = None, None try: downloaded, etag, modified, data = self.__downloadConditionally(url, etag, modified) except urllib.error.HTTPError as e: log.notice('Could not download %s: %s', url, e) return False, e.code if downloaded: with open(os.path.join(self.path, filename), 'wb') as f: f.write(data) self.cache[filename] = (etag, modified) cachePath = os.path.join(self.path, 'cache.ini') with open(cachePath, 'w') as f: f.write(mh.formatINI(self.cache)) return True, (200 if downloaded else 304)
def upgrade_from_batch(r, b): f = chroot.popen("rpm --test -F %s 2>&1" % string.join(b.files), user = "******") killset = {} rx = re.compile(r' \(installed\) (?P<name>[^\s]+)-[^-]+-[^-]+$') for l in f.xreadlines(): m = rx.search(l) if m: killset[m.group('name')] = 1 f.close() if len(killset) != 0: err = close_killset(killset) if err != "": util.append_to(b.logfile, err) log.notice("cannot upgrade rpms") return False k = string.join(killset.keys()) if True: b.log_line("upgrade requires removal of %s" % k) res = chroot.run("rpm -e %s" % k, logfile = b.logfile, user = "******") if res != 0: b.log_line("package removal failed") return False else: b.log_line("packages removed sucessfuly") else: b.log_line("upgrade would need removal of %s" % k) return False b.log_line("upgrading packages") logbuf = StringIO.StringIO() res = chroot.run("rpm -Fvh %s" % string.join(b.files), user = "******", logfile = b.logfile) if res != 0: b.log_line("package upgrade failed") logbuf.close() return False logbuf.close() return True
def generate(name, opts, header = None, footer = None): r = ['RTEMS Tools Project - Source Builder Error Report'] + [] if header: r += [' %s' % (header)] r += [opts.info()] if opts.defaults.get_value('%{_sbgit_valid}') == '1': r += [' %s/%s' % (opts.defaults.get_value('%{_sbgit_remotes}'), opts.defaults.get_value('%{_sbgit_id}'))] else: r += [' RSB: not a valid repo'] r += [' %s' % (' '.join(os.uname()))] r += [] r += ['Tail of the build log:'] r += log.tail() if footer: r += [footer] try: name = name.replace('/', '-') l = open(name, 'w') l.write(os.linesep.join(r)) l.close() log.notice(' See error report: %s' % (name)) except: log.stderr('error: failure to create error report') raise
def _git_downloader(url, local, config, opts): rlp = os.path.relpath(path.host(local)) us = url.split('?') repo = git.repo(local, opts, config.macros) if not repo.valid(): log.notice('git: clone: %s -> %s' % (us[0], rlp)) if not opts.dry_run(): repo.clone(us[0], local) for a in us[1:]: _as = a.split('=') if _as[0] == 'branch': log.notice('git: checkout: %s => %s' % (us[0], _as[1])) if not opts.dry_run(): repo.checkout(_as[1]) elif _as[0] == 'pull': log.notice('git: pull: %s' % (us[0])) if not opts.dry_run(): repo.pull() elif _as[0] == 'fetch': log.notice('git: fetch: %s -> %s' % (us[0], rlp)) if not opts.dry_run(): repo.fetch() elif _as[0] == 'reset': arg = [] if len(_as) > 1: arg = ['--%s' % (_as[1])] log.notice('git: reset: %s' % (us[0])) if not opts.dry_run(): repo.reset(arg) return True
def run(): import sys try: _opts = options.load(args=sys.argv, logfile=False) log.notice('RTEMS Source Builder - Check, %s' % (version.str())) orphans = _opts.parse_args('--check-orphans', error=False, extra=False) if orphans: print('Checking for orphans...') check_orphans(_opts) else: if host_setup(_opts): print('Environment is ok') else: print('Environment is not correctly set up') except error.general as gerr: print(gerr) sys.exit(1) except error.internal as ierr: print(ierr) sys.exit(1) except error.exit as eerr: pass except KeyboardInterrupt: log.notice('abort: user terminated') sys.exit(1) sys.exit(0)
def onMouseDown(self, event): human = gui3d.app.selectedHuman # Find the target name if self.micro: folder = 'data/targets/microdetails/' part = gui3d.app.selectedGroup.name else: folder = 'data/targets/details/' part = human.getPartNameForGroupName(gui3d.app.selectedGroup.name) # Find the targets leftTarget = '%s%s%s.target' % (folder, part, self.left) rightTarget = '%s%s%s.target' % (folder, part, self.right) self.modifier = None if not (leftTarget and rightTarget): log.notice('No targets available') return self.modifier = humanmodifier.Modifier(leftTarget, rightTarget) # Save the state self.before = {} self.before[leftTarget] = human.getDetail(leftTarget) self.before[rightTarget] = human.getDetail(rightTarget) # Add symmetry targets if needed self.symmetryModifier = None if human.symmetryModeEnabled: symmetryPart = human.getSymmetryPart(part) if symmetryPart: if self.left.find('trans-in') != -1 or self.left.find( 'trans-out') != -1: leftSymmetryTarget = '%s%s%s.target' % ( folder, symmetryPart, self.right) rightSymmetryTarget = '%s%s%s.target' % ( folder, symmetryPart, self.left) else: leftSymmetryTarget = '%s%s%s.target' % ( folder, symmetryPart, self.left) rightSymmetryTarget = '%s%s%s.target' % ( folder, symmetryPart, self.right) self.symmetryModifier = humanmodifier.Modifier( leftSymmetryTarget, rightSymmetryTarget) # Save the state self.before[leftSymmetryTarget] = human.getDetail( leftSymmetryTarget) self.before[rightSymmetryTarget] = human.getDetail( rightSymmetryTarget) if human.isSubdivided(): human.meshData.setVisibility(1) human.getSubdivisionMesh(False).setVisibility(0)
def loadHandler(self, human, values): mhuv = values[1] if not os.path.exists(os.path.realpath(mhuv)): log.notice('UvTaskView.loadHandler: %s does not exist. Skipping.', mhuv) return self.setUv(human, mhuv)
def run(args): ec = 0 try: optargs = {"--list-configs": "List available configurations"} opts = options.load(args, optargs) log.notice("RTEMS Source Builder, Package Builder v%s" % (version.str())) if not check.host_setup(opts): if not opts.force(): raise error.general("host build environment is not set up" + " correctly (use --force to proceed)") log.notice("warning: forcing build with known host setup problems") if opts.get_arg("--list-configs"): configs = get_configs(opts) for p in configs["paths"]: print "Examining: %s" % (os.path.relpath(p)) for c in configs["files"]: if c.endswith(".cfg"): print " %s" % (c) else: for config_file in opts.config_files(): b = build(config_file, True, opts) b.make() b = None except error.general, gerr: log.stderr("Build FAILED") ec = 1
def send_html_report(doc, payload, subject, recipient_list): """ Create message container - the correct MIME type is multipart/alternative. Record the MIME types of both parts - text/plain and text/html. Send the message via local SMTP server. sendmail function takes 3 arguments: sender smtp_session address, recipient smtp_session address and message to send - here it is sent as one string. :type doc: str :type payload: str :type subject: str :type recipient_list: list """ msg = MIMEMultipart('alternative') msg['Subject'] = subject msg['From'] = config.from_address recipients = recipient_list msg['To'] = ', '.join(recipients) part = MIMEBase('application', "octet-stream") part.set_payload(payload) part2 = MIMEText(str(doc), 'html') encode_base64(part) part.add_header('Content-Disposition', 'attachment; filename="text.html"') msg.attach(part) smtp_session = smtplib.SMTP('smtp-dev.lab.il.infinidat.com') log.notice( "Sending summary report to the following recipients: {0}".format( recipients)) smtp_session.sendmail(config.from_address, recipients, msg.as_string()) smtp_session.quit()
def main(srv_ssl=False): write_css() write_js() socket.setdefaulttimeout(30) try: init_conf() host = "" port = config.request_handler_server_port if srv_ssl: port = config.request_handler_server_ssl_port try: server = HTTPServer((host, port), MyHandler) if srv_ssl: server.socket = ssl.wrap_socket( server.socket, keyfile=config.request_handler_server_ssl_key, certfile=config.request_handler_server_ssl_cert, ca_certs="/etc/certs/ca-certificates.crt", server_side=True) except Exception, e: log.notice( "request_handler_server: can't start server on [%s:%d], ssl=%s: %s" % (host, port, str(srv_ssl), e)) print >> sys.stderr, "ERROR: Can't start server on [%s:%d], ssl=%s: %s" % ( host, port, str(srv_ssl), e) sys.exit(1) log.notice('request_handler_server: started on [%s:%d], ssl=%s...' % (host, port, str(srv_ssl))) server.serve_forever()
def preinstall(topdir, jobs): if type(jobs) is str: jobs = int(jobs) start_time = datetime.datetime.now() makes = [] for am in _collect(topdir, 'Makefile.am'): if _grep(am, 'include .*/preinstall\.am'): makes += [am] next = 0 ampolish3s = [] while next < len(makes) or len(ampolish3s) > 0: if next < len(makes) and len(ampolish3s) < jobs: log.notice('%3d/%3d: ampolish3: %s' % \ (next + 1, len(makes), makes[next][len(topdir) + 1:])) ampolish3s += [ampolish3(topdir, makes[next])] next += 1 else: for ap in ampolish3s: if not ap.is_alive(): ap.post_process() ampolish3s.remove(ap) del ap if len(ampolish3s) >= jobs: time.sleep(1) end_time = datetime.datetime.now() log.notice('Preinstall time: %s' % (str(end_time - start_time)))
def makeImages(self,text_file): mh.redraw() ret = [] try: log.notice(self.cam.zoomFactor) self.cam.zoomFactor = 3.5 pos = self.human.getPosition() pos[1] = -7 self.human.setPosition(pos) mh.redraw() ret.append(self.makeImage([0,0,0])) ret.append(self.makeImage([-10, 0, 0])) ret.append(self.makeImage([-20, 0, 0])) ret.append(self.makeImage([-30, 0, 0])) ret.append(self.makeImage([10, 0, 0])) ret.append(self.makeImage([20, 0, 0])) ret.append(self.makeImage([0, -10, 0])) ret.append(self.makeImage([0, -20, 0])) ret.append(self.makeImage([0, -30, 0])) ret.append(self.makeImage([0, 10, 0])) ret.append(self.makeImage([0, 20, 0])) ret.append(self.makeImage([0, 30, 0])) self.human.setRotation([0, 0, 0]) mh.redraw() except Exception as e: print(e) text_file.write(str(e)) return ret
def dbConnect(hostname, username, password, database): global databaseConnections thread_name = currentThread().getName() if thread_name not in databaseConnections: log.notice("Establishing new database connection in thread {}".format(thread_name)) databaseConnections[thread_name] = MySQLdb.connect(host = hostname, user = username, passwd = password, db = database) databaseConnections[thread_name].autocommit(True)
def generate(name, opts, header = None, footer = None): label, result = opts.with_arg('error-report') if (label.startswith('without_') and result != 'yes') or \ (label.startswith('with_') and result != 'no'): r = ['RTEMS Tools Project - Source Builder Error Report'] + [] if header: r += [' %s' % (header)] r += [opts.info()] if opts.defaults.get_value('%{_sbgit_valid}') == '1': r += [' %s/%s' % (opts.defaults.get_value('%{_sbgit_remotes}'), opts.defaults.get_value('%{_sbgit_id}'))] else: r += [' RSB: not a valid repo'] if os.name == 'nt': r += [' Windows'] else: r += [' %s' % (' '.join(os.uname()))] r += [] r += ['Tail of the build log:'] r += log.tail() if footer: r += [footer] try: name = name.replace('/', '-') with open(name, 'w') as l: l.write(os.linesep.join(r)) log.notice(' See error report: %s' % (name)) except: log.stderr('error: failure to create error report') raise
def run(args): try: optargs = { '--rtems': 'The RTEMS source directory', '--rtems-bsp': 'The RTEMS BSP (arch/bsp)', '--list': 'List the configurations' } opts = options.load(sys.argv, optargs) if opts.get_arg('--rtems'): prefix = opts.get_arg('--rtems')[1] else: prefix = os.getcwd() if opts.get_arg('--rtems-bsp') is None: raise error.general('no --rtems-bsp option; please provide') bsp = bsp_config(opts, prefix, opts.get_arg('--rtems-bsp')[1]) if opts.get_arg('--list'): log.notice('RTEMS Source Builder - RTEMS Configuration, v%s' % (version.str())) opts.log_info() configs = bsp.keys() for c in sorted(configs.keys()): print c else: for p in opts.params(): print bsp.find(p) except error.general, gerr: print gerr sys.exit(1)
def _hash_check(file_, absfile, macros, remove=True): failed = False hash = sources.get_hash(file_.lower(), macros) if hash is not None: hash = hash.split() if len(hash) != 2: raise error.internal('invalid hash format: %s' % (file_)) try: hashlib_algorithms = hashlib.algorithms except: hashlib_algorithms = [ 'md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512' ] if hash[0] not in hashlib_algorithms: raise error.general('invalid hash algorithm for %s: %s' % (file_, hash[0])) if hash[0] in ['md5', 'sha1']: raise error.general('hash: %s: insecure: %s' % (file_, hash[0])) hasher = None _in = None try: hasher = hashlib.new(hash[0]) _in = open(path.host(absfile), 'rb') hasher.update(_in.read()) except IOError as err: log.notice('hash: %s: read error: %s' % (file_, str(err))) failed = True except: msg = 'hash: %s: error' % (file_) log.stderr(msg) log.notice(msg) if _in is not None: _in.close() raise if _in is not None: _in.close() hash_hex = hasher.hexdigest() hash_base64 = base64.b64encode(hasher.digest()).decode('utf-8') log.output('checksums: %s: (hex: %s) (b64: %s) => %s' % (file_, hash_hex, hash_base64, hash[1])) if hash_hex != hash[1] and hash_base64 != hash[1]: log.warning('checksum error: %s' % (file_)) failed = True if failed and remove: log.warning('removing: %s' % (file_)) if path.exists(absfile): try: os.remove(path.host(absfile)) except IOError as err: raise error.general('hash: %s: remove: %s' % (absfile, str(err))) except: raise error.general('hash: %s: remove error' % (file_)) if hasher is not None: del hasher else: if version.released(): raise error.general('%s: no hash found in released RSB' % (file_)) log.warning('%s: no hash found' % (file_)) return not failed
def _hash_check(file_, absfile, macros, remove=True): failed = False hash = sources.get_hash(file_.lower(), macros) if hash is not None: hash = hash.split() if len(hash) != 2: raise error.internal('invalid hash format: %s' % (file_)) try: hashlib_algorithms = hashlib.algorithms except: hashlib_algorithms = [ 'md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512' ] if hash[0] not in hashlib_algorithms: raise error.general('invalid hash algorithm for %s: %s' % (file_, hash[0])) hasher = None _in = None try: hasher = hashlib.new(hash[0]) _in = open(path.host(absfile), 'rb') hasher.update(_in.read()) except IOError, err: log.notice('hash: %s: read error: %s' % (file_, str(err))) failed = True except:
def loadProxy(human, path, type="Clothes"): try: npzpath = os.path.splitext(path)[0] + '.mhpxy' try: if not os.path.isfile(npzpath): log.message('compiled proxy file missing: %s', npzpath) raise RuntimeError('compiled proxy file missing: %s', npzpath) if os.path.isfile(path) and os.path.getmtime(path) > os.path.getmtime(npzpath): log.message('compiled proxy file out of date: %s', npzpath) raise RuntimeError('compiled file out of date: %s', npzpath) proxy = loadBinaryProxy(npzpath, human, type) except Exception as e: showTrace = not isinstance(e, RuntimeError) log.warning("Problem loading binary proxy: %s", e, exc_info=showTrace) proxy = loadTextProxy(human, path, type) # TODO perhaps proxy type should be stored in .mhclo file too if getpath.isSubPath(npzpath, getpath.getPath()): # Only write compiled binary proxies to user data path try: saveBinaryProxy(proxy, npzpath) except StandardError: log.notice('unable to save compiled proxy: %s', npzpath, exc_info=True) else: log.debug('Not writing compiled proxies to system paths (%s).', npzpath) except: log.error('Unable to load proxy file: %s', path, exc_info=True) return None return proxy
def run(args): try: optargs = { '--rtems': 'The RTEMS source directory', '--rtems-bsp': 'The RTEMS BSP (arch/bsp)', '--list': 'List the configurations' } opts = options.load(sys.argv, optargs) if opts.get_arg('--rtems'): prefix = opts.get_arg('--rtems')[1] else: prefix = os.getcwd() if opts.get_arg('--rtems-bsp') is None: raise error.general('no --rtems-bsp option; please provide') bsp = bsp_config(opts, prefix, opts.get_arg('--rtems-bsp')[1]) if opts.get_arg('--list'): log.notice('RTEMS Source Builder - RTEMS Configuration, %s' % (version.str())) opts.log_info() configs = bsp.keys() for c in sorted(configs.keys()): print c else: for p in opts.params(): print bsp.find(p) except error.general, gerr: print gerr sys.exit(1)
def run(args): ec = 0 try: optargs = { '--list-configs': 'List available configurations' } opts = options.load(args, optargs) log.notice('RTEMS Source Builder, Package Builder v%s' % (version.str())) if not check.host_setup(opts): if not opts.force(): raise error.general('host build environment is not set up' + ' correctly (use --force to proceed)') log.notice('warning: forcing build with known host setup problems') if opts.get_arg('--list-configs'): configs = get_configs(opts) for p in configs['paths']: print 'Examining: %s' % (os.path.relpath(p)) for c in configs['files']: if c.endswith('.cfg'): print ' %s' % (c) else: for config_file in opts.config_files(): b = build(config_file, True, opts) b.make() b = None except error.general, gerr: log.stderr('Build FAILED') ec = 1
def run(): import sys try: # # Run where defaults.mc is located # long_opts = { # key macro handler param defs init '--file' : ('_file', 'path', True, None, False) } opts = options.command_line(base_path = '.', argv = sys.argv, long_opts = long_opts) options.load(opts) s = file(opts.defaults['_file'], opts) s.load(opts.defaults['_file']) print(s) del s except error.general as gerr: print(gerr) sys.exit(1) except error.internal as ierr: print(ierr) sys.exit(1) except KeyboardInterrupt: log.notice('abort: user terminated') sys.exit(1) sys.exit(0)
def path_check(opts, silent=False): if 'PATH' in os.environ: paths = os.environ['PATH'].split(os.pathsep) for p in paths: try: if len(p.strip()) == 0: if not silent: log.notice( 'error: environment PATH contains an empty path') return False elif not options.host_windows and (p.strip() == '.' or p.strip() == '..'): if not silent: log.notice('error: environment PATH invalid path: %s' % (p)) return False elif not path.exists(p): if not silent and opts.warn_all(): log.notice('warning: environment PATH not found: %s' % (p)) elif not path.isdir(p): if not silent and opts.warn_all(): log.notice( 'warning: environment PATH not a directory: %s' % (p)) except Exception as e: if not silent: log.notice( 'warning: environment PATH suspicious path: %s' % (e)) return True
def getSelectedBone(self): for (name, button) in self.boneButtons.items(): if button.selected: #print "Bone", name, "selected" return self.armature.bones[name] log.notice("BUG: No bone selected") return None
def run(args): ec = 0 try: optargs = {'--list-configs': 'List available configurations'} opts = options.load(args, optargs) log.notice('RTEMS Source Builder, Package Builder v%s' % (version.str())) if not check.host_setup(opts): if not opts.force(): raise error.general('host build environment is not set up' + ' correctly (use --force to proceed)') log.notice('warning: forcing build with known host setup problems') if opts.get_arg('--list-configs'): configs = get_configs(opts) for p in configs['paths']: print 'Examining: %s' % (os.path.relpath(p)) for c in configs['files']: if c.endswith('.cfg'): print ' %s' % (c) else: for config_file in opts.config_files(): b = build(config_file, True, opts) b.make() b = None except error.general, gerr: log.stderr('Build FAILED') ec = 1
def run(args): try: long_opts = { # key macro handler param defs init '--test-path': ('_test_path', 'path', True, None, False), '--test-jobs': ('_test_jobs', 'jobs', True, 'max', True), '--test-bool': ('_test_bool', 'bool', False, '0', True) } opts = command_line(base_path='.', argv=args, optargs=None, defaults=macros.macros(), long_opts=long_opts, command_path='.') load(opts) log.notice('RTEMS Tools Project - Defaults, v%s' % (version.str())) opts.log_info() log.notice('Options:') log.notice(str(opts)) log.notice('Defaults:') log.notice(str(opts.defaults)) except error.general as gerr: print(gerr) sys.exit(1) except error.internal as ierr: print(ierr) sys.exit(1) except error.exit: pass except KeyboardInterrupt: _notice(opts, 'abort: user terminated') sys.exit(1) sys.exit(0)
def _check_exe(_opts, macro, value, constraint, silent = False): if len(value) == 0 or constraint == 'none': return True orig_value = value if path.isabspath(value): if path.isfile(value): return True if os.name == 'nt': if path.isfile('%s.exe' % (value)): return True value = path.basename(value) absexe = True else: absexe = False paths = os.environ['PATH'].split(os.pathsep) if _check_paths(value, paths): if absexe: if not silent: log.notice('warning: exe: absolute exe found in path: (%s) %s' % (macro, orig_value)) return True if constraint == 'optional': if not silent: log.trace('warning: exe: optional exe not found: (%s) %s' % (macro, orig_value)) return True if not silent: log.notice('error: exe: not found: (%s) %s' % (macro, orig_value)) return False
def run(args): try: long_opts = { # key macro handler param defs init '--test-path' : ('_test_path', 'path', True, None, False), '--test-jobs' : ('_test_jobs', 'jobs', True, 'max', True), '--test-bool' : ('_test_bool', 'bool', False, '0', True) } opts = command_line(base_path = '.', argv = args, optargs = None, defaults = macros.macros(), long_opts = long_opts, command_path = '.') load(opts) log.notice('RTEMS Tools Project - Defaults, v%s' % (version.str())) opts.log_info() log.notice('Options:') log.notice(str(opts)) log.notice('Defaults:') log.notice(str(opts.defaults)) except error.general as gerr: print(gerr) sys.exit(1) except error.internal as ierr: print(ierr) sys.exit(1) except error.exit: pass except KeyboardInterrupt: _notice(opts, 'abort: user terminated') sys.exit(1) sys.exit(0)
def loadMesh(path, locX=0, locY=0, locZ=0, loadColors=1): """ This function loads the specified mesh object into internal MakeHuman data structures, and returns it. The loaded file should be in Wavefront OBJ format. Parameters: ----------- path: *String*. The file system path to the file containing the object to load. locX: *float* X location of loaded obj, default = 0 locY: *float* Y location of loaded obj, default = 0 locZ: *float* Z location of loaded obj, default = 0 """ name = os.path.basename(path) obj = module3d.Object3D(name) obj.path = path obj.x = locX obj.y = locY obj.z = locZ try: npzpath = os.path.splitext(path)[0] + '.npz' try: if not os.path.isfile(npzpath): log.message('compiled file missing: %s', npzpath) raise RuntimeError() if os.path.isfile(path) and os.path.getmtime(path) > os.path.getmtime(npzpath): log.message('compiled file out of date: %s', npzpath) raise RuntimeError() loadBinaryMesh(obj, npzpath) except: loadTextMesh(obj, path) if isSubPath(npzpath, getPath('')): # Only write compiled binary meshes to user data path try: saveBinaryMesh(obj, npzpath) except Exception: log.notice('unable to save compiled mesh: %s', npzpath) else: log.debug('Not writing compiled meshes to system paths (%s).', npzpath) except: log.error('Unable to load obj file: %s', path, exc_info=True) return False obj.updateIndexBuffer() obj.calcNormals() return obj
def _check_dir(_opts, macro, value, constraint, silent = False): if constraint != 'none' and not path.isdir(value): if constraint == 'required': if not silent: log.notice('error: dir: not found: (%s) %s' % (macro, value)) return False if not silent and _opts.warn_all(): log.notice('warning: dir: not found: (%s) %s' % (macro, value)) return True
def toggleProfiling(self): import profiler if self.actions.profiling.isChecked(): profiler.start() log.notice('profiling started') else: profiler.stop() log.notice('profiling stopped') mh.changeTask('Utilities', 'Profile')
def _check_dir(_opts, macro, value, constraint, silent=False): if constraint != 'none' and not path.isdir(value): if constraint == 'required': if not silent: log.notice('error: dir: not found: (%s) %s' % (macro, value)) return False if not silent and _opts.warn_all(): log.notice('warning: dir: not found: (%s) %s' % (macro, value)) return True
def toggleProfiling(self): import profiler if self.actions.profiling.isChecked(): profiler.start() log.notice('profiling started') else: profiler.stop() log.notice('profiling stopped') mh.changeTask('Develop', 'Profile')
def loadMesh(path, loadColors=1, maxFaces=None, obj=None): """ This function loads the specified mesh object into internal MakeHuman data structures, and returns it. The loaded file should be in Wavefront OBJ format. Parameters: ----------- path: *String*. The file system path to the file containing the object to load. Note: loadColors is currently unused maxFaces: *uint* Number of faces per vertex (pole), None for default (min 4) """ name = os.path.basename(path) if obj is None: obj = module3d.Object3D(name) if maxFaces: obj.MAX_FACES = maxFaces obj.path = path try: npzpath = os.path.splitext(path)[0] + '.npz' try: if not os.path.isfile(npzpath): log.message('compiled file missing: %s', npzpath) raise RuntimeError('compiled file missing: %s', npzpath) if os.path.isfile(path) and os.path.getmtime( path) > os.path.getmtime(npzpath): log.message('compiled file out of date: %s', npzpath) raise RuntimeError('compiled file out of date: %s', npzpath) loadBinaryMesh(obj, npzpath) except Exception as e: showTrace = not isinstance(e, RuntimeError) log.warning("Problem loading binary mesh: %s", e, exc_info=showTrace) loadTextMesh(obj, path) if isSubPath(npzpath, getPath('')): # Only write compiled binary meshes to user data path try: saveBinaryMesh(obj, npzpath) except StandardError: log.notice('unable to save compiled mesh: %s', npzpath) else: log.debug('Not writing compiled meshes to system paths (%s).', npzpath) except: log.error('Unable to load obj file: %s', path, exc_info=True) return False return obj
def loadHandler(self, human, values): if len(values) >= 3: mhclo = export_config.getExistingProxyFile(values[1], values[2], "clothes") else: mhclo = export_config.getExistingProxyFile(values[1], None, "clothes") if not mhclo: log.notice("%s does not exist. Skipping.", values[1]) else: self.setClothes(human, mhclo)
def dbDisconnect(): global databaseConnections thread_name = currentThread().getName() if databaseConnections.get(thread_name): log.notice("Disconnected from database in thread {!r}".format(thread_name)) databaseConnections[thread_name].close() databaseConnections.pop(thread_name) else: log.error("Connection does not exist for thread {!r}".format(thread_name)) log.debug("Current connections: {}".format(databaseConnections))
def _file_downloader(url, local, config, opts): if not path.exists(local): try: src = url[7:] dst = local log.notice('download: copy %s -> %s' % (src, dst)) path.copy(src, dst) except: return False return True
def get_file(url, local, opts, config): if local is None: raise error.general('source/patch path invalid') if not path.isdir(path.dirname(local)) and not opts.download_disabled(): log.notice('Creating source directory: %s' % \ (os.path.relpath(path.host(path.dirname(local))))) log.output('making dir: %s' % (path.host(path.dirname(local)))) if _do_download(opts): path.mkdir(path.dirname(local)) if not path.exists(local) and opts.download_disabled(): raise error.general('source not found: %s' % (path.host(local))) # # Check if a URL has been provided on the command line. If the package is # release push to the start the RTEMS URL. # url_bases = opts.urls() if version.released(): rtems_release_url = config.macros.expand('%{rtems_release_url}/%{rsb_version}/sources') log.trace('release url: %s' % (rtems_release_url)) # # If the URL being fetched is under the release path do not add the # sources release path because it is already there. # if not url.startswith(rtems_release_url): if url_bases is None: url_bases = [rtems_release_url] else: url_bases.append(rtems_release_url) urls = [] if url_bases is not None: # # Split up the URL we are being asked to download. # url_path = urlparse.urlsplit(url)[2] slash = url_path.rfind('/') if slash < 0: url_file = url_path else: url_file = url_path[slash + 1:] log.trace('url_file: %s' %(url_file)) for base in url_bases: if base[-1:] != '/': base += '/' next_url = urlparse.urljoin(base, url_file) log.trace('url: %s' %(next_url)) urls.append(next_url) urls += url.split() log.trace('_url: %s -> %s' % (','.join(urls), local)) for url in urls: for dl in downloaders: if url.startswith(dl): if downloaders[dl](url, local, config, opts): return if _do_download(opts): raise error.general('downloading %s: all paths have failed, giving up' % (url))