def datadir(self): """Returns the datadir of this LilyPond instance. Most times this is something like "/usr/share/lilypond/2.13.3/" If this method returns False, the datadir could not be determined. """ if not self.abscommand(): return False # First ask LilyPond itself. j = job.Job([self.abscommand(), '-e', "(display (ly:get-option 'datadir)) (newline) (exit)"]) @j.done.connect def done(): success = j.success if success: output = [line[0] for line in j.history()] d = output[1].strip('\n') if os.path.isabs(d) and os.path.isdir(d): self.datadir = d return # Then find out via the prefix. if self.prefix(): dirs = ['current'] if self.versionString(): dirs.append(self.versionString()) for suffix in dirs: d = os.path.join(self.prefix(), 'share', 'lilypond', suffix) if os.path.isdir(d): self.datadir = d return self.datadir = False app.job_queue().add_job(j, 'generic')
def preview(self, text, title=None, base_dir=None, temp_dir='', cached=False): """Runs LilyPond on the given text and shows the resulting PDF.""" self.abort_running() if cached: self._running = j = job.lilypond.CachedPreviewJob( text, target_dir=temp_dir, base_dir=base_dir, title=title) if not self._running.needs_compilation(): self._done(None) return else: self._running = j = job.lilypond.VolatileTextJob(text, title=title) j.done.connect(self._done) if self._showLog: self._log.clear() self._log.connectJob(j) self._stack.setCurrentWidget(self._log) if self._showProgress: j.started.connect( lambda: self._progress.start(self._lastbuildtime)) self._progress.start(self._lastbuildtime) if self._showWaiting: self._waiting.start() app.job_queue().add_job(j, 'generic')
def run_job(self, job): """Run a job.Job().""" self.setMessage(_("Please wait until the command finishes")) self.setStandardButtons(('cancel', )) self.job = job self.log.connectJob(job) job.done.connect(self._done) app.job_queue().add_job(job, 'generic')
def preview(self, text, title=None): """Runs LilyPond on the given text and shows the resulting PDF.""" j = self._running = job.lilypond.VolatileTextJob(text, title) j.done.connect(self._done) self._log.clear() self._log.connectJob(j) app.job_queue().add_job(j, 'generic') self._progress.start(self._lastbuildtime)
def run_job(self, job): """Run a job.Job().""" self.setMessage(_("Please wait until the command finishes")) self.setStandardButtons(('cancel',)) self.job = job self.log.connectJob(job) job.done.connect(self._done) app.job_queue().add_job(job, 'generic')
def versionString(self): if not self.abscommand(): return "" j = job.Job([self.abscommand(), '--version']) @j.done.connect def done(): success = j.success if success: output = ' '.join([line[0] for line in j.history()]) m = re.search(r"\d+\.\d+(.\d+)?", output) self.versionString = m.group() if m else "" else: self.versionString = "" app.job_queue().add_job(j, 'generic')
def run(self): """Runs convert-ly (again).""" fromVersion = self.fromVersion.text() toVersion = self.toVersion.text() if not fromVersion or not toVersion: self.messages.setPlainText(_( "Both 'from' and 'to' versions need to be set.")) return info = self._info command = info.toolcommand(info.ly_tool('convert-ly')) command += ['-f', fromVersion, '-t', toVersion, '-'] self.job = j = job.Job(command, encoding='utf-8') if QSettings().value("lilypond_settings/no_translation", False, bool): j.environment['LANG'] = 'C' j.environment['LC_ALL'] = 'C' else: j.environment.pop('LANG', None) j.environment.pop('LC_ALL', None) j.done.connect(self.slotJobDone) app.job_queue().add_job(j, 'generic') j._process.write(self._text.encode('utf-8')) j._process.closeWriteChannel()
def run(self): """Runs convert-ly (again).""" fromVersion = self.fromVersion.text() toVersion = self.toVersion.text() if not fromVersion or not toVersion: self.messages.setPlainText(_( "Both 'from' and 'to' versions need to be set.")) return info = self._info command = info.toolcommand('convert-ly') command += ['-f', fromVersion, '-t', toVersion, '-'] self.job = j = job.Job(command, encoding='utf-8') if QSettings().value("lilypond_settings/no_translation", False, bool): j.environment['LANG'] = 'C' j.environment['LC_ALL'] = 'C' else: j.environment.pop('LANG', None) j.environment.pop('LC_ALL', None) j.done.connect(self.slotJobDone) app.job_queue().add_job(j, 'generic') j._process.write(self._text.encode('utf-8')) j._process.closeWriteChannel()