def GetTmuxSessionNames(): #{{{ ListSessions = system('tmux list-sessions') if not ListSessions.startswith(connectFailed): ListSessions = system("tmux list-sessions -F '#S'") return ListSessions.split("\n") else: return []
def GetTmuxNPanes(SName): #{{{ ListSessions = system('tmux list-sessions') if not ListSessions.startswith(connectFailed): NPanes = system("tmux list-windows -t "+SName+" -F '#{window_panes}'") return NPanes.split("\n") else: return []
def GetTmuxWindowNames(SName): #{{{ ListSessions = system('tmux list-sessions') if not ListSessions.startswith(connectFailed): ListWindows = system("tmux list-windows -t " + SName + " -F '#W'") return ListWindows.split("\n") else: return []
def GetTmuxWindowNames(SName): #{{{ ListSessions = system('tmux list-sessions') if not ListSessions.startswith(connectFailed): ListWindows = system("tmux list-windows -t "+SName+" -F '#W'") return ListWindows.split("\n") else: return []
def GetTmuxNPanes(SName): #{{{ ListSessions = system('tmux list-sessions') if not ListSessions.startswith(connectFailed): NPanes = system("tmux list-windows -t " + SName + " -F '#{window_panes}'") return NPanes.split("\n") else: return []
def play(target): movie = get_movie(target) log('Using movie at {}'.format(movie)) subtitles = get_subtitles(target) log('Using subtitles at {}'.format(subtitles)) if platform.system() == 'Windows': system([r'C:\Program Files (x86)\VideoLAN\VLC\vlc.exe', movie, '--sub-file', subtitles]) else: os.system("echo 'on 0' | cec-client -s") system_child([r'omxplayer', movie, '--subtitles', subtitles, '-b'])
def GetTmuxWorkspace(): #{{{ # NOTE: This function will die soon! ListSessions = system('tmux list-sessions') if not ListSessions.startswith(connectFailed): ListSessions = ListSessions.split("\n") Sessions = [] for i in range(len(ListSessions)): ListSessions[i] = ListSessions[i].split("windows")[0].split(":")[0] Sessions.append({'name': ListSessions[i], 'windows': []}) for i in range(len(Sessions)): ListWindows = system('tmux list-windows -t ' + Sessions[i]['name']) ListWindows = ListWindows.split("\n") for j in range(len(ListWindows)): # Search for Number and Name find = re.findall(r"[0-9]+: [\w]+", ListWindows[j]) find = find[0].split(":") WNumber = int(find[0]) WName = find[1].strip() # Search for Size WSize = re.findall(r"\[[\d]+x[\d]+\]", ListWindows[j])[0].strip(r"(?:[|])") # Search for Layout WLayout = re.findall(r"\[layout [\d\w,\[\]\{\}]+\]", ListWindows[j])[0].strip(r"[layout") WLayout = re.sub(r"]$", "", WLayout) # Search for Number of Panes NPanes = int( re.findall(r"\([\d]+ panes\)", ListWindows[j])[0].strip(r"(?:\(|panes\))")) Window = {} Window['WName'] = WName Window['WNumber'] = WNumber Window['WSize'] = WSize Window['WLayout'] = WLayout.strip() Window['NPanes'] = NPanes Sessions[i]['windows'].append(Window) #print(ListWindows[j]) print(dump(Sessions[0])) stream = open("samples/Project.yml", 'r') pprint(load(stream))
def GetTmuxWorkspace(): #{{{ # NOTE: This function will die soon! ListSessions = system('tmux list-sessions') if not ListSessions.startswith(connectFailed): ListSessions = ListSessions.split("\n") Sessions = [] for i in range(len(ListSessions)): ListSessions[i] = ListSessions[i].split("windows")[0].split(":")[0] Sessions.append({'name':ListSessions[i],'windows':[]}) for i in range(len(Sessions)): ListWindows = system('tmux list-windows -t '+Sessions[i]['name']) ListWindows = ListWindows.split("\n") for j in range(len(ListWindows)): # Search for Number and Name find = re.findall(r"[0-9]+: [\w]+",ListWindows[j]) find = find[0].split(":") WNumber = int(find[0]) WName = find[1].strip() # Search for Size WSize = re.findall(r"\[[\d]+x[\d]+\]",ListWindows[j])[0].strip(r"(?:[|])") # Search for Layout WLayout = re.findall(r"\[layout [\d\w,\[\]\{\}]+\]",ListWindows[j])[0].strip(r"[layout") WLayout = re.sub(r"]$","",WLayout) # Search for Number of Panes NPanes = int(re.findall(r"\([\d]+ panes\)",ListWindows[j])[0].strip(r"(?:\(|panes\))")) Window = {} Window['WName'] = WName Window['WNumber'] = WNumber Window['WSize'] = WSize Window['WLayout'] = WLayout.strip() Window['NPanes'] = NPanes Sessions[i]['windows'].append(Window) #print(ListWindows[j]) print(dump(Sessions[0])) stream = open("samples/Project.yml",'r') pprint(load(stream))
def checkHerokuCli(): # Checks if heroku executable is installed if not which("heroku"): # Log progress progress = log.progress("Installing heroku cli") # Commands to install heroku commands = [ "wget -q https://cli-assets.heroku.com/install.sh", "sh intall.sh", "rm install.sh" ] # For each command run it on a shell for command in commands: system(command.split(), stdout=DEVNULL) # Log success progress.success("Done") else: # Log success log.success("%s found" % which("heroku"))
def checkChiselBinary(): # Checks if chisel binary is present if not path.exists("chisel"): # Commands to install chisel commands = [ "wget -q https://github.com/jpillora/chisel/releases/download/1.3.1/chisel_linux_amd64.gz", "gunzip -f -q chisel_linux_amd64.gz", "mv chisel_linux_amd64 chisel", "chmod +x chisel" ] # Log progress progress = log.progress("Setting up chisel") # For each command run it on a shell for command in commands: system(command.split()) # Log success progress.success("Done") else: # Log success log.success("%s/chisel found" % getcwd())
def execute(name, username, password): # Log log.info("Lauching proxy...") # Store variables credentials = "%s:%s" % (username, password) url = "https://%s.herokuapp.com" % name # Attempt to spawn chisel try: # Log warning log.warn("Press CTRL-C to destroy your proxy") # Run chisel to connect to the server system([ "./chisel", "client", "--keepalive", "10s", "--auth", credentials, url, "socks" ], stdout=DEVNULL) except KeyboardInterrupt: # Log progress = log.progress("Destroying your app") # Stop proxy client system("pkill chisel".split()) # Destroy app terminate(name) # Log success progress.success("Done") finally: # Log progress progress = log.progress("Logging out") # Logout system("heroku logout".split(), stdout=DEVNULL) # Log success progress.success("Done")
def createApp(name, username, password): # Progress progress = log.progress("Creating a heroku app") # Proxy password env_password = "******" % (username, password) # Create the app system(["heroku", "apps:create", name], stdout=DEVNULL) system(["heroku", "stack:set", "container"], stdout=DEVNULL) system(["heroku", "config:set", env_password], stdout=DEVNULL) # Deploy system("git push heroku master".split(), stdout=DEVNULL) # Log success progress.success("Done") # Log info log.info("App deployed at: https://%s.herokuapp.com" % name)
def LoadYAMLs(FilesDirectory): #{{{ YAMLs = [] Files = system('ls ' + FilesDirectory).split("\n") for SNumber in range(len(Files)): File = FilesDirectory + '/' + Files[SNumber] try: Stream = open(File, 'r') try: YAMLs.append(load(Stream)) except: pass Stream.close() except: pass return YAMLs
def LoadYAMLs(FilesDirectory): #{{{ YAMLs = [] Files = system('ls '+FilesDirectory).split("\n") for SNumber in range(len(Files)): File = FilesDirectory+'/'+Files[SNumber] try: Stream = open(File,'r') try: YAMLs.append(load(Stream)) except: pass Stream.close() except: pass return YAMLs
def run(self): ''' Perform a run of this application. ''' if (os_name != 'posix'): import platform pf = platform.system() raise SystemError('No UNIX-like environment. ' + "You are currently using platform '%s', " % (pf)+ 'and cannot run a binary in a shell.') elif (self.exeName and not exeExists(self.exeName)): raise SystemError("'%s' is not installed on your system." % ( self.exeName)) sproc = system(self.getInstructionString(),stdout=PIPE, stderr=PIPE,shell=True) return sproc.communicate()[0]
def run(self): ''' Perform a run of this application. ''' if (os_name != 'posix'): import platform pf = platform.system() raise SystemError('No UNIX-like environment. ' + "You are currently using platform '%s', " % (pf) + 'and cannot run a binary in a shell.') elif (self.exeName and not exeExists(self.exeName)): raise SystemError("'%s' is not installed on your system." % (self.exeName)) sproc = system(self.getInstructionString(), stdout=PIPE, stderr=PIPE, shell=True) return sproc.communicate()[0]
text = text.replace('"', '"') return text from collections import defaultdict data = defaultdict(list) fp = open(sys.argv[1], 'r') annotations = json.loads(fp.read()) for annotation in annotations: name = annotation['name'] split = annotation['split'] data[split].append(name) from subprocess import call as system system('mkdir -p subshot-annotator', shell=True) print( '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>' ) sorted_splits = sorted(data.keys(), key=lambda x: -len(data[x])) for split in sorted_splits: fp = open('subshot-annotator/%s.html' % split, 'w') print( '<a href="subshot-annotator/%s.html"><img src="splits/%s.png"> %s</a><br>\n' % (split, split, split)) fp.write( '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">' #+ '<script lang="javascript" src="../jquery-1.10.2.min.js"></script>' #+ '<script lang="javascript" src="../filter.js"></script>' #+ '<script lang="javascript" src="../subshot-annotator.js"></script>'
for subshot in annotation['subshots']: output += '<li>' + subshot['type'] + '<ul>' for person in subshot['persons']: output += '<li>' + person['role'] + ' ' + person['location'] + ' ' + person['pose'] + '</li>' output += '</ul></li>' output += '</ol>' return output unlabeled = [] for name in sorted(images.keys()): if name not in data: unlabeled.append(name) from subprocess import call as system system('mkdir -p viewer', shell=True) print('<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>') label_id = 0 sorted_labels = sorted(labels.keys(), key=lambda x: -sum([len(y) for y in labels[x]])) for label in sorted_labels: fp = open('viewer/%d.html' % label_id, 'w') print('<a href="viewer/%d.html">%s</a><br>\n' % (label_id, protect(label))) label_id += 1 fp.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>\n') fp.write('<h1>' + protect(label) + '</h1>\n') fp.write(label_to_html(label_as_annotation[label])) for show in sorted(labels[label]): fp.write('<hr><h3>' + show + '</h3>\n') for name in labels[label][show]: fp.write('<a href="%s" target="annotator"><img src="%s" width="192" height="108" title="%s"></a>\n' % ('../' + '/'.join(images[name].split('/')[:-3]) + '/index.html?' + name, 'http://talep.lif.univ-mrs.fr/percol/' + images[name] + '.192', name)) fp.write('</body></html>')
for person in subshot['persons']: output += '<li>' + person['role'] + ' ' + person[ 'location'] + ' ' + person['pose'] + '</li>' output += '</ul></li>' output += '</ol>' return output unlabeled = [] for name in sorted(images.keys()): if name not in data: unlabeled.append(name) from subprocess import call as system system('mkdir -p viewer', shell=True) print( '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>' ) label_id = 0 sorted_labels = sorted(labels.keys(), key=lambda x: -sum([len(y) for y in labels[x]])) for label in sorted_labels: fp = open('viewer/%d.html' % label_id, 'w') print('<a href="viewer/%d.html">%s</a><br>\n' % (label_id, protect(label))) label_id += 1 fp.write( '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>\n' ) fp.write('<h1>' + protect(label) + '</h1>\n') fp.write(label_to_html(label_as_annotation[label]))
def run_control(name): system(['./dbuscontrol.sh', name])
for subshot in annotation['subshots']: output += '<li>' + subshot['type'] + '<ul>' for person in subshot['persons']: output += '<li>' + person['role'] + ' ' + person['location'] + ' ' + person['pose'] + '</li>' output += '</ul></li>' output += '</ol>' return output unlabeled = [] for name in sorted(images.keys()): if name not in data: unlabeled.append(name) from subprocess import call as system system('mkdir -p viewer.dev2', shell=True) print('<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>') label_id = 0 sorted_labels = sorted(labels.keys(), key=lambda x: -sum([len(y) for y in labels[x]])) for label in sorted_labels: fp = open('viewer.dev2/%d.html' % label_id, 'w') print('<a href="viewer.dev2/%d.html">%s</a><br>\n' % (label_id, protect(label))) label_id += 1 fp.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>\n') fp.write('<h1>' + protect(label) + '</h1>\n') fp.write(label_to_html(label_as_annotation[label])) for show in sorted(labels[label]): fp.write('<hr><h3>' + show + '</h3>\n') for name in labels[label][show]: fp.write('<a href="%s" target="annotator"><img src="%s" width="192" height="108" title="%s"></a>\n' % ('../' + '/'.join(images[name].split('/')[:-3]) + '/index.html?' + name, 'http://talep.lif.univ-mrs.fr/percol/' + images[name] + '.192', name)) fp.write('</body></html>')
def terminate(name): # Destroy an app system(["heroku", "apps:destroy", name, "-c", name])
for person in subshot['persons']: output += '<li>' + person['role'] + ' ' + person[ 'location'] + ' ' + person['pose'] + '</li>' output += '</ul></li>' output += '</ol>' return output unlabeled = [] for name in sorted(images.keys()): if name not in data: unlabeled.append(name) from subprocess import call as system system('mkdir -p viewer.dev2', shell=True) print( '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>' ) label_id = 0 sorted_labels = sorted(labels.keys(), key=lambda x: -sum([len(y) for y in labels[x]])) for label in sorted_labels: fp = open('viewer.dev2/%d.html' % label_id, 'w') print('<a href="viewer.dev2/%d.html">%s</a><br>\n' % (label_id, protect(label))) label_id += 1 fp.write( '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>\n' ) fp.write('<h1>' + protect(label) + '</h1>\n')