def marge_json(): template_main_json_path = os.path.join(DIR_SOURCE_FONT, TAMPLATE_MAIN_JSON) template_glyf_json_path = os.path.join(DIR_SOURCE_FONT, TAMPLATE_GLYF_JSON) template_json_path = os.path.join(DIR_SOURCE_FONT, TAMPLATE_JSON) cmd = "jq -n --argfile o1 {} --argfile o2 {} '$o1 | select(1).glyf |= $o2' > {}".format( template_main_json_path, template_glyf_json_path, template_json_path) shell.process(cmd)
def process(data, file, host='root@localhost', port='22', pre=''): """ Uses since to retrive last line of a remote file """ """ Warning this can be harmful as the ssh command is excuted as is: """ """ You might want to create a dedicated user for reading logs """ files = file if isinstance(file, list) else [file] # FIXME: Should return stdout, and log stderr # use paramiko.SSHClient(): http://stackoverflow.com/a/3586168 cmd = 'ssh -p %s %s "%s"' % (port, host, '; '.join(['%s since %s'%(pre,file) for file in files])) return shell.process(data=None, command=cmd)
def _Restart(self, evt): ## print "_Restart" if evt and not isinstance(evt, tuple): self._close(evt) del self.queue[:] self.killsteps = killsteps[:] if self.restartable: ## print "Restartable!" d = '' if self.filter: wp = which_python if ' ' in wp: wp = '"%s"' % wp c = python_cmd % wp else: c = command elif isinstance(evt, tuple) and len(evt) == 2: ## print "Starting!" d, c = evt else: ## print "quitting!" return if d: x = os.getcwd() try: os.chdir(d) except: self.write("could not switch to %r\n" % d) return self.remote = shell.process(self, c, self.Restart) if d: os.chdir(x) print "Process started, pid=%i" % self.remote.process.pid remote.append(self.remote) self.restart = 0
def make_new_cmap_table_json(): temp_json_path = os.path.join(DIR_TEMP, TEMP_JSON) cmap_json_path = os.path.join(DIR_TEMP, CMAP_JSON) cmd = "cat {} | jq '.cmap' > {}".format(temp_json_path, cmap_json_path) shell.process(cmd)
def convert_otf2json(source_font_name): temp_json_path = os.path.join(DIR_TEMP, TEMP_JSON) cmd = "otfccdump -o {} --pretty {}".format(temp_json_path, source_font_name) shell.process(cmd)
def convert_json2otf(output_font_name): template_json_path = os.path.join(DIR_SOURCE_FONT, TAMPLATE_JSON) output_font_path = os.path.join(DIR_OUTPUT_FONT, output_font_name) cmd = "otfccbuild {} -o {}".format(template_json_path, output_font_path) shell.process(cmd)
def delete_glyf_table_on_main_json(): template_temp_json_path = os.path.join(p.DIR_TEMP, TAMPLATE_TEMP_JSON) template_main_json_path = os.path.join(p.DIR_TEMP, TAMPLATE_MAIN_JSON) cmd = "cat {} | jq '.glyf |= map_values( (select(1).contours |= []) // .)' > {}".format(template_temp_json_path, template_main_json_path) shell.process(cmd)
def make_new_glyf_table_json(): template_temp_json_path = os.path.join(p.DIR_TEMP, TAMPLATE_TEMP_JSON) template_glyf_json_path = os.path.join(p.DIR_TEMP, TAMPLATE_GLYF_JSON) cmd = "cat {} | jq '.glyf' > {}".format(template_temp_json_path, template_glyf_json_path) shell.process(cmd)