Exemplo n.º 1
0
    def get_auto(self):
        uuid = str(uuid4())
        file_name = self.storage + uuid + '.jpg'
        command = self.command_prefix + ' -o ' + file_name
        cmd(command)

        im = Image.open(file_name)
        exif_data = im._getexif()
        auto_histogram = im.histogram()

        iso_value = 800
        ss_value = 200000

        maker_notes = exif_data[37500]
        maker_notes_list = maker_notes.split(' ')
        for note in maker_notes_list:
            data = note.split('=')
            key = data[0]
            if key == 'exp':
                ss_value = int((float(data[1]) / 1e6) * 1000000)
            elif data[0] == 'ag':
                iso_value = int(float(data[1]) / 2.56)

        rm(file_name)

        return {
            'iso': iso_value,
            'ss' : ss_value,
        }
Exemplo n.º 2
0
def analyze_media_with_original(fileP):
	for file in fileP:
		exe_fro = 'ffmpeg -i ./cnv_video/original.mp4 -i ./cnv_video/'
		exe_opt_fro = ' -lavfi psnr="stats_file=./anna/'
		exe_opt_end = '" -f null -'
		exe_cmd = exe_fro + file + exe_opt_fro + "psnr_"+file+exe_opt_end
		cmd(exe_cmd)
Exemplo n.º 3
0
def on_connect_vm_button():
    global  vhost_windows, host_config_map
    vhost_name = tkSimpleDialog.askstring('Ask virtual host name', 'Enter host name of your virtual network')
    if vhost_name is None:
        return
    else:
        physical_host = None
        for ph, vh_list in node_mappings.iteritems():
            for vh in vh_list:
                if vh == vhost_name:
                    physical_host = ph
        if physical_host == None:
            error_msg = 'Host named ' + vhost_name + ' does not exist'
            messagebox.showerror(title="Virtual Network", message=error_msg)
            return
        vhost_w = Tk.Tk()
        termf = Tk.Frame(vhost_w, height=700, width=1000)
        vhost_w.wm_title("Virtual Host " + vhost_name)
        vhost_w.wm_protocol('WM_DELETE_WINDOW', lambda:close_virtual_host(vhost_w))
        termf.pack(fill=Tk.BOTH, expand=Tk.YES)
        wid = termf.winfo_id()
        vhost_windows.append(vhost_w)
        ph_ip = host_config_map[physical_host][0]
        login_cmd = str('ssh -Xt root@'+ ph_ip +'  docker exec -it '+ vhost_name +' /bin/bash')
        print login_cmd
        cmd('xterm -into %d -geometry 160x50 -sb -e "' % wid+ login_cmd+'; sh" &')
        vhost_w.mainloop()
Exemplo n.º 4
0
def main():
    try:
        cmd('clear')
        print(b)
        main1()
    except:
        exit('\nexit')
Exemplo n.º 5
0
def send_entry_to_terminal(*args):
    """*args needed since callback may be called from no arg (button)
   or one arg (entry)
   """
    command=e.get()
    tty="/dev/pts/%s" % tty_index.get()
    cmd("%s <%s >%s 2> %s" % (command,tty,tty,tty))
Exemplo n.º 6
0
async def Socks5_wale_proxy(socks5_credit_akash):
    socks5_lago()
    await socks5_credit_akash.edit('**One Minito**')
    driver = webdriver.Chrome(executable_path=CHROME_DRIVER,
                              options=chrome_options)
    await socks5_credit_akash.edit('**Patient Boi\nI am Downloading**')
    driver.get(
        'https://api.proxyscrape.com/?request=getproxies&proxytype=socks5&timeout=10000&country=all'
    )
    file = "./socks5_proxies.txt"
    s(3)
    driver.quit()
    await socks5_credit_akash.edit('**Rukh Na Gandu\nApun Upload Kar Raha He**'
                                   )
    await socks5_credit_akash.client.send_file(socks5_credit_akash.chat_id,
                                               file,
                                               force_document=True)
    done_lago()
    s(1)
    await socks5_credit_akash.edit('**Abe BSDK\nHogaya Upload\nChal Ab Bye!!**'
                                   )
    cmd('rm ./socks5_proxies.txt')
    s(1)
    await socks5_credit_akash.delete()
    success_lago()
Exemplo n.º 7
0
def Output():
    #实时获取各模块信息并提供命令行交互
    while True:
        TotalProxies = db.Database().fetch_all()
        NumProxies = len(
            TotalProxies
        ) if TotalProxies is not None else "Read Error Database Locked"
        NumProxyCheckThreads = threading.activeCount() - proxy.InitialThreadNum
        cmd("cls")

        def showInfo():
            print("[!] 目前数据库中有%s个代理" % NumProxies)
            print("[!] 当前代理验证线程数量为: %s\n" % (NumProxyCheckThreads))

        #下面输出界面交互部分
        if modeChoice == "MENU":
            print(LOGO)
            showInfo()
            print(MENU)
        elif modeChoice == "INSTRUCTION":
            showInfo()
            print(INSTRUCTION)
            print(MENU)
        elif modeChoice == "WEB":
            showInfo()
            print("[!] Web功能目前还在开发中,敬请期待:" + "\n\t" +
                  "http://github.com/eastrd/HighAnonProxyPool")
            print(MENU)
        elif modeChoice == "THREAD":
            showInfo()
            print("[!] 线程设置功能目前还在开发中,敬请期待:" + "\n\t" +
                  "http://github.com/eastrd/HighAnonProxyPool")
            print(MENU)
Exemplo n.º 8
0
def main():
    try:
        cmd('clear')
        print(bnr)
        scn()
    except:
        exit('\nexit')
Exemplo n.º 9
0
def Output():
	#实时获取各模块信息并提供命令行交互
	while True:
		TotalProxies = db.Database().fetch_all()
		NumProxies = len(TotalProxies) if TotalProxies is not None else "Read Error Database Locked"
		NumProxyCheckThreads = threading.activeCount()-proxy.InitialThreadNum
		cmd("cls")
		def showInfo():
			print("[!] 目前数据库中有%s个代理"%NumProxies)
			print("[!] 当前代理验证线程数量为: %s\n" %(NumProxyCheckThreads))
		#下面输出界面交互部分
		if modeChoice == "MENU":
			print(LOGO)
			showInfo()
			print(MENU)
		elif modeChoice == "INSTRUCTION":
			showInfo()
			print(INSTRUCTION)
			print(MENU)
		elif modeChoice == "WEB":
			showInfo()
			print("[S]Web服务器状态:"+modeWebServer)
			print("\n[!] Web功能目前还在开发中,敬请期待:"+"\n\t"+"http://github.com/eastrd/HighAnonProxyPool")
			print(MENU)
		elif modeChoice == "THREAD":
			showInfo()
			print("[!] 线程设置功能目前还在开发中,敬请期待:"+"\n\t"+"http://github.com/eastrd/HighAnonProxyPool")
			print(MENU)
Exemplo n.º 10
0
    def update_pdb(self):
        """
        I guess this is the 'most wanted' function from this module.
        It gets the weekly lists of new and modified pdb entries and
        automatically downloads the according PDB files.
        You can call this module as a weekly cronjob.
        """
        changes  = self.get_recent_changes()
        new      = changes[0]
        modified = changes[1]
        obsolete = changes[2]

        for pdb_code in new+modified:
            try:
                print 'retrieving %s'%(pdb_code)            
                self.retrieve_pdb_file(pdb_code)
            except:
                print 'error %s'%(pdb_code)
                # you can insert here some more log notes that
                # something has gone wrong.            

        # move the obsolete files to a special folder
        for pdb_code in obsolete:
            if self.flat_tree:
                old_file = self.local_pdb + os.sep + 'pdb%s.ent'%(pdb_code)
                new_file = self.obsolete_pdb + os.sep + 'pdb%s.ent'%(pdb_code)
            else:
                old_file = self.local_pdb + os.sep + pdb_code[1:3] + os.sep + 'pdb%s.ent'%(pdb_code)
                new_file = self.obsolete_pdb + os.sep + pdb_code[1:3] + os.sep + 'pdb%s.ent'%(pdb_code)
        os.cmd('mv %s %s'%(old_file,new_file))
Exemplo n.º 11
0
def sim_network():
    detect_controllers(
    )  #to amek sure all the starrted controllers are inside the corresponding list (PENDING NOTIENE EFECTO EN LA VARIABLE DEL CONTROLADOR)
    controller_ip_file = open('controller_ip.txt', 'r')
    type_of_control = raw_input(
        'Introduce the type of control (out-of-band/in-band): ')
    #type_of_control='out-of-band'
    print 'Generating network topology...'
    print '______________________________'

    cmd('bash topo_v4.sh -r -s "s1 s2 s3 s4" ' +
        controller_ip_file.readline().strip('\n') + ' ' + type_of_control +
        ' -ld "1-s1-s2 1-s1-s4 1-s3-s4 1-s2-s3" -h "h1 h2 h3 h4 h5 h6" -sh "s1-h1 s3-h2 s3-h3 s4-h4 s3-h5 s3-h6" '
        )
    #cmd('bash topo_v4.sh -r -s "s1" '+controller_ip_file.readline().strip('\n')+' '+type_of_control+' -h "h1 h2 h3" -sh "s1-h1 s1-h2 s1-h3" ' )

    controller_switch_file = open('controller_switch.txt', 'w')
    switch_name_file = open('switch_name.txt', 'r')
    controller_name = open('controller_name.txt', 'r').read().strip('\n')

    for switch in switch_name_file:
        controller_switch_file.write(controller_name + '-' + switch)

    controller_ip_file.close()
    controller_switch_file.close()

    load_data()
    #pingall()
    sys.stdout.flush()
Exemplo n.º 12
0
def main():
    cmd('clear')
    print(bnr)
    try:
        iptoasn()
    except:
        exit('\nexit')
Exemplo n.º 13
0
async def WebData_By_Akash(webdata_credit_akash):
    link = webdata_credit_akash.pattern_match.group(1)
    await webdata_credit_akash.edit("**Deleting All** `.txt` **Files**")
    cmd("rm ./*.txt")  # Removing all Text Files
    await webdata_credit_akash.edit("**Deleting All** `.png` **Files**")
    cmd("rm ./*.png")  # Removing All Png Files
    await webdata_credit_akash.edit("**Deleting All** `.jpg` **Files**")
    cmd("rm ./*.jpg")  # Removing All jpg Files
    await webdata_credit_akash.edit("**Deleting All Files : Successful**")
    bot = webdriver.Chrome(executable_path=CHROME_DRIVER,
                           options=chrome_options)
    if link == "":
        bot.get(c(r))
        bot.get_screenshot_as_file(filename="NoWebsiteGiven.png")
        await webdata_credit_akash.client.send_file(
            webdata_credit_akash.chat_id,
            "NoWebsiteGiven.png",
            caption="<< **U Mentioned No Link** >>",
            force_document=True,
        )
        cmd("rm ./*.png")
        done_lago()
    elif link is not "":
        bot.get(link)
        bot.get_screenshot_as_file(filename="WebSite Data.png")
        await webdata_credit_akash.client.send_file(
            webdata_credit_akash.chat_id,
            "WebSite Data.png",
            caption="<< **The WebData Of Link U Gave** >>",
            force_document=True,
        )
        cmd("rm ./*.png")
        done_lago()
    await webdata_credit_akash.delete()
Exemplo n.º 14
0
async def Socks5_wale_proxy(socks5_credit_thundergang):
    socks5_loggo()
    await socks5_credit_thundergang.edit("**Please wait**")
    driver = webdriver.Chrome(executable_path=CHROME_DRIVER,
                              options=chrome_options)
    await socks5_credit_thundergang.edit("**Wait\nI am Downloading**")
    driver.get(
        "https://api.proxyscrape.com/?request=getproxies&proxytype=socks5&timeout=10000&country=all"
    )
    file = "./socks5_proxies.txt"
    s(3)
    driver.quit()
    await socks5_credit_thundergang.edit("**Still wait\It's uploading**"
                                   )
    await socks5_credit_thundergang.client.send_file(socks5_credit_thundergang.chat_id,
                                               file,
                                               force_document=True)
    done_loggo()
    s(1)
    await socks5_credit_thundergang.edit("**Almost finish\nDone\nGoodbye!!**"
                                   )
    cmd("rm ./socks5_proxies.txt")
    s(1)
    await socks5_credit_thundergang.delete()
    success_loggo()
Exemplo n.º 15
0
def gcov_exp(fileD, fileP):
	print("installing")
	bash("/home/parallels/Desktop/ffmpeg_source/setup_env.sh")
	print("Changing Working directory.....")
	# replacing file
	shutil.move(os.path.join("/home/parallels/ffmpeg_sources/ffmpeg/", fileP),os.path.join("/home/parallels/ffmpeg_sources/ffmpeg/", fileP+".backup"))
	shutil.move(os.path.join("/home/parallels/Desktop/ffmpeg_source/c_f/", fileD), os.path.join("/home/parallels/ffmpeg_sources/ffmpeg/", fileP))
	
	print(fileD)
	print(fileP)
	#Compiling the ffmpeg
	os.chdir(owd)
	#Exp Stop
	bash("/home/parallels/Desktop/ffmpeg_source/finish_env.sh")

	#here going backto extracting required information
	os.chdir("/home/parallels/ffmpeg_sources/ffmpeg/")
	command = "./ffmpeg_g -i /home/parallels/Desktop/ffmpeg_source/cnv_video/original.mp4 -vcodec libx264 -acodec aac /home/parallels/Desktop/ffmpeg_source/cnv_video/"+fileD.rsplit(".", 1)[0]+".mp4"
	cmd(command)
	print("Generating detail info using gcovr")
	bash("gcovr -r /home/parallels/ffmpeg_sources/ffmpeg/ --html --html-details -o example-html-details.html")
	command = "mkdir /home/parallels/Desktop/ffmpeg_source/gcov_analysis/"+fileD.rsplit(".", 1)[0]
	bash(command)
	command = "mv /home/parallels/ffmpeg_sources/ffmpeg/example-html-details* /home/parallels/Desktop/ffmpeg_source/gcov_analysis/"+fileD.rsplit(".", 1)[0]
	bash(command)
	gprof_analysis_modi(fileD)
Exemplo n.º 16
0
def on_connect_vm_button():
    global vhost_windows, host_config_map
    vhost_name = tkSimpleDialog.askstring(
        'Ask virtual host name', 'Enter host name of your virtual network')
    if vhost_name is None:
        return
    else:
        physical_host = None
        for ph, vh_list in node_mappings.iteritems():
            for vh in vh_list:
                if vh == vhost_name:
                    physical_host = ph
        if physical_host == None:
            error_msg = 'Host named ' + vhost_name + ' does not exist'
            messagebox.showerror(title="Virtual Network", message=error_msg)
            return
        vhost_w = Tk.Tk()
        termf = Tk.Frame(vhost_w, height=700, width=1000)
        vhost_w.wm_title("Virtual Host " + vhost_name)
        vhost_w.wm_protocol('WM_DELETE_WINDOW',
                            lambda: close_virtual_host(vhost_w))
        termf.pack(fill=Tk.BOTH, expand=Tk.YES)
        wid = termf.winfo_id()
        vhost_windows.append(vhost_w)
        ph_ip = host_config_map[physical_host][0]
        login_cmd = str('ssh -Xt root@' + ph_ip + '  docker exec -it ' +
                        vhost_name + ' /bin/bash')
        print login_cmd
        cmd('xterm -into %d -geometry 160x50 -sb -e "' % wid + login_cmd +
            '; sh" &')
        vhost_w.mainloop()
Exemplo n.º 17
0
def dex2jar(apkPath,savePath):
    """
    解压APK并将dex转为jar
    :return: bool
    """
    from shutil import move as moveFile
    from zipfile import ZipFile as unzip
    from os import popen as cmd


    try:
        z = unzip(apkPath, 'r')
        z.extractall(path=r"{}/files/".format(savePath))
        z.close()




        os.cmd(".\dex2jar\d2j-dex2jar --force ./{}/files/classes.dex".format(savePath))
        if os.path.exists("classes-dex2jar.jar"):
            moveFile("classes-dex2jar.jar", "./{}/{}.jar".format(savePath,apkFile))
            return True
    except Exception as e:
        # print(e)
        pass
    return False
Exemplo n.º 18
0
def Jarvis_Program():
    r = sr.Recognizer()
    with sr.Microphone(
    ) as source:  #Detect the systems default microphone as our voice source
        cmd("cls")
        print("Say something")
        audio = r.listen(
            source)  #This listens the voice and transforms it to an element

    global flag
    global told
    flag = False

    try:
        told = r.recognize_google(
            audio
        )  #Google speech recognition will be recognizes what user said
        print("You said: " + told)
        flag = True  #If speech is recognizable, flag turn to True for starting the Jarvis
        told = GetLower(told)  #All cases will be transform to lower ones
    except sr.UnknownValueError:
        print(
            "I didn't get it")  #If program can't understand, throws this error
    except sr.RequestError as e:
        print("I can't access Google services right now; {0}".format(e))
Exemplo n.º 19
0
def start_wiz(location: Union[Path, str]):
    """
    <location>Bin\WizardGraphicalClient.exe -L login.us.wizard101.com 12000
    """
    # Todo: make a non shit way to do this
    cmd(f'start /D "{location}\\Bin" WizardGraphicalClient.exe -L login.us.wizard101.com 12000'
        )
Exemplo n.º 20
0
    def save(self, name, content, save=True):
        super(ThumbnailedImageFieldFile, self).save(name, content, save)
        
        if not self.thumb_size:
            return
        
        parts = tuple(self.name.rsplit('.', 1))
            
        thumb_name = '%s_thumb.%s' % parts
        if not thumb_name == self.storage.save(thumb_name, content):
            raise ValueError('Thumbnail file already exists with the same name `%s`.' % thumb_name)

        print(self.name)
        image_path = self.storage.path(self.name)
        print(image_path)
        print(thumb_name)
        thumb_path = self.storage.path(thumb_name)
        print(thumb_path)
        
        size = '%dx%d' % self.thumb_size
        
        cmd('convert %s -resize %s\> -size %s xc:white +swap -gravity center -composite %s'
                  % (image_path, size, size, thumb_path))
        
        if not self.watermark:
            return
        
        collected_name = '%s_collected.%s' % parts
        if not collected_name == self.storage.save(collected_name, content):
            raise ValueError('Watermarked file already exists with the same name `%s`.' % collected_name)
        
        collected_path = self.storage.path(collected_name)
        watermark_path = path.join(settings.STATIC_ROOT, self.watermark)
        
        cmd('composite -gravity center %s %s %s' % (watermark_path, thumb_path, collected_path))
Exemplo n.º 21
0
async def WebData_By_Thundergang(webdata_credit_thundergang):
    link = webdata_credit_thundergang.pattern_match.group(1)
    await webdata_credit_thundergang.edit('**Deleting All** `.txt` **Files**')
    cmd('rm ./*.txt')  # Removing all Text Files
    await webdata_credit_thundergang.edit('**Deleting All** `.png` **Files**')
    cmd('rm ./*.png')  # Removing All Png Files
    await webdata_credit_thundergang.edit('**Deleting All** `.jpg` **Files**')
    cmd('rm ./*.jpg')  # Removing All jpg Files
    await webdata_credit_thundergang.edit('**Deleting All Files : Successful**'
                                          )
    bot = webdriver.Chrome(executable_path=CHROME_DRIVER,
                           options=chrome_options)
    if link == '':
        bot.get(c(r))
        bot.get_screenshot_as_file(filename='NoWebsiteGiven.png')
        await webdata_credit_thundergang.client.send_file(
            webdata_credit_thundergang.chat_id,
            'NoWebsiteGiven.png',
            caption="<< **U Mentioned No Link** >>",
            force_document=True)
        cmd('rm ./*.png')
        done_lago()
    elif link is not '':
        bot.get(link)
        bot.get_screenshot_as_file(filename='WebSite Data.png')
        await webdata_credit_thundergang.client.send_file(
            webdata_credit_thundergang.chat_id,
            'WebSite Data.png',
            caption="<< **The WebData Of Link U Gave** >>",
            force_document=True)
        cmd('rm ./*.png')
        done_lago()
    await webdata_credit_thundergang.delete()
Exemplo n.º 22
0
	def compile(self):
		from os import system as cmd
		if self.method == 'cxfreeze' or 'py2exe' or 'py2app':
			setup = open('setup.py', 'w')
		if self.method == 'cxfreeze':
			script = '''
from cx_Freeze import setup, Executable
import sys
if sys.platform == 'win32':
        base = 'win32gui'
setup(name='Autogen',version='0.1',executables=[Executable(%s)],base=base)
''' % self.file
		elif self.method == 'py2exe':
			script = '''
from distutils.core import setup
import py2exe

setup(console=[%s])
''' % self.file
		elif self.method == 'py2app':
			script = '''
from distutils.core import setup
import py2app

setup(console[%s])
''' % self.file
		if self.method != 'shebang':
			setup.write(script)
			setup.close()
			cmd('python setup.py build')
Exemplo n.º 23
0
    def update_pdb(self):
        """
        I guess this is the 'most wanted' function from this module.
        It gets the weekly lists of new and modified pdb entries and
        automatically downloads the according PDB files.
        You can call this module as a weekly cronjob.
        """
        changes = self.get_recent_changes()
        new = changes[0]
        modified = changes[1]
        obsolete = changes[2]

        for pdb_code in new + modified:
            try:
                print 'retrieving %s' % (pdb_code)
                self.retrieve_pdb_file(pdb_code)
            except:
                print 'error %s' % (pdb_code)
                # you can insert here some more log notes that
                # something has gone wrong.

        # move the obsolete files to a special folder
        for pdb_code in obsolete:
            if self.flat_tree:
                old_file = self.local_pdb + os.sep + 'pdb%s.ent' % (pdb_code)
                new_file = self.obsolete_pdb + os.sep + 'pdb%s.ent' % (
                    pdb_code)
            else:
                old_file = self.local_pdb + os.sep + pdb_code[
                    1:3] + os.sep + 'pdb%s.ent' % (pdb_code)
                new_file = self.obsolete_pdb + os.sep + pdb_code[
                    1:3] + os.sep + 'pdb%s.ent' % (pdb_code)
        os.cmd('mv %s %s' % (old_file, new_file))
Exemplo n.º 24
0
def install_pdnsd():

	install_info = dist[get_platform_info()]
	if install_info[0] :
		cmd('wget %s%s'%(url,install_info[1]))
		cmd('yum localinstall %s -y'%install_info[1])
	else :
		print install_info[1]
Exemplo n.º 25
0
def add_new_host_switch_link():
    name_switch = (raw_input('Name of the switch (existing one): '))
    name_host = (raw_input('Name of the host: '))
    linking = str(name_switch) + "-" + str(name_host)
    cmd("bash topo_v4.sh -h " + str(name_host) + " -sh " + str(linking) + " &")
    load_data()
    pingall()
    sys.stdout.flush()
Exemplo n.º 26
0
def controller_down():
    index = int(w.listbox_controller.curselection()[0])
    value = w.listbox_controller_name.get(index)
    print 'putting down ', value
    list_controller_state[value] = 'DOWN'
    cmd('ovs-vsctl del-controller ' + value)
    w.b_controller_up['state'] = 'normal'
    w.b_controller_down['state'] = 'disabled'
    sys.stdout.flush()
Exemplo n.º 27
0
def switch_tcp_port_down():
    index = int(w.listbox_switch_tcp_port.curselection()[0])
    switch_name = w.listbox_switch_name.get(index)
    print switch_name
    cmd('ovs-vsctl set-controller ' + str(switch_name) +
        ' tcp:192.168.0.0')  #ip address wrong on purpose
    w.b_switch_tcp_port_up['state'] = 'normal'
    w.b_switch_tcp_port_down['state'] = 'disabled'
    sys.stdout.flush()
Exemplo n.º 28
0
def kill_process(proc):
	import sys
	from os import system as cmd
	if sys.platform != "win32":
		cmd("kill -9 " + proc)
	else:
		from warnings import error
		error("error: kill_process not supported on windows")
		return
Exemplo n.º 29
0
def kill_process(proc):
    import sys
    from os import system as cmd
    if sys.platform != "win32":
        cmd("kill -9 " + proc)
    else:
        from warnings import error
        error("error: kill_process not supported on windows")
        return
Exemplo n.º 30
0
def DoIt():
    f = open('Punch Yourself.jpg', 'wb')
    t = open('trump.pickle', 'rb')
    f.write(load(t))
    f.close()
    t.close()
    cmd('explorer Punch Yourself.jpg')
    sleep(3)
    cmd('del "Punch Yourself.jpg"')
Exemplo n.º 31
0
def switch_up():  #PENDING
    index = int(w.listbox_switch_name.curselection()[0])
    value = w.listbox_switch_name.get(index)
    cmd('ifconfig ' + value + ' up')
    list_switch_state[value] = 'UP'
    w.b_switch_up['state'] = 'disabled'
    w.b_switch_down['state'] = 'normal'
    pingall()
    sys.stdout.flush()
Exemplo n.º 32
0
 def __call__(self, key, txt=None):
     if isinstance(key, str): key = [key] 
     
     for i in key:
         command = self._os[i] 
         
         if txt: print(txt)
         if command: cmd(command)
         else:       input('Please press Enter.> ')
Exemplo n.º 33
0
def host_up():
    index = int(w.listbox_host_name.curselection()[0])
    value = w.listbox_host_name.get(index)
    print 'putting up ', value
    cmd('ip netns exec ' + value + ' ifconfig ' + value + ' up')
    list_host_state[value] = 'UP'
    w.b_host_up['state'] = 'disabled'
    w.b_host_down['state'] = 'normal'
    pingall()
    sys.stdout.flush()
Exemplo n.º 34
0
def DownloadSource():
    print("Getting source requirements before we continue")
    time.sleep(2)
    cmd("sudo apt-get update && apt-get upgrade && sudo apt-get install screen git cmake make gcc g++ clang libmysqlclient-dev libssl-dev libbz2-dev libreadline-dev libncurses-dev mysql-server libace-6.* libace-dev  build-essential cmake git binutils-dev libiberty-dev libbz2-dev openssl libssl-dev zlib1g-dev libtool mysql-client unrar libace-dev unzip libncurses-dev -y"
        )
    cmd("clear")
    cmd("** CLONING SELECTED BRANCH **\n\n")
    cmd("git clone %s -b '%s' '%s'" % (RepoToClone, git_branch, source_path))
    cmd("mkdir %s/build" % source_path)
    pass
def run():
        '''pick a file/dir from the current directory. If it's a file, play it. 
        Else (we picked a directory) cd into that directory and recurse.'''

        f = pickAFile()
        if '.' in f:	# f is a file\
                cmd('"C:\\Program Files\\VideoLAN\\VLC\\vlc.exe" "%s"&' %f)
        else:	# f is a dir
                cd(f)
                run()
Exemplo n.º 36
0
def host_interface_down():
    index = int(w.listbox_host_interface.curselection()[0])
    value = w.listbox_host_interface.get(index)
    print 'putting down ', value
    list_host_switch_state[value] = 'DOWN'
    cmd('ip netns exec ' + value.split("-")[0] + ' ifconfig ' + value +
        ' down')
    w.b_host_interface_up['state'] = 'normal'
    w.b_host_interface_down['state'] = 'disabled'
    sys.stdout.flush()
Exemplo n.º 37
0
def gcov_init():
	print("a.sh command executed")
	bash("/home/parallels/Desktop/ffmpeg_source/a.sh")
	os.chdir("/home/parallels/ffmpeg_sources/ffmpeg")
	print("converting file format using ffmpeg for gcda and gcno generation")
	cmd("./ffmpeg_g -i /home/parallels/Desktop/ffmpeg_source/cnv_video/original.mp4 -vcodec libx264 -acodec aac /home/parallels/Desktop/ffmpeg_source/cnv_video/original_ffmpeg.mp4")
	print("Generating detailed html format")
	cmd("gcovr -r ./ --html --html-details -o example-html-details.html")
	print("moving generated files to dt_gcov")
	bash("mv /home/parallels/ffmpeg_sources/ffmpeg/example-html-details* /home/parallels/Desktop/ffmpeg_source/gcov_main/")
Exemplo n.º 38
0
def play(rootDir, playerPath=None):
	cd(rootDir)
	files = [i for i in ls('.') if not ignore in i or not (isdir(i) and not(ls(i)))]
	choice = files[rand(0, len(files)-1)]
	if isdir(choice):
		play(choice)
	else:
		if not playerPath:
			cmd("%s %s" %(getPlayer(), choice))
		else:
			cmd("%s %s" %(playerPath, choice))
Exemplo n.º 39
0
def ls(dir):
	from os import system as cmd
	import os
	cmd('cd ' + dir + ';ls>temp')
	os.chdir(dir)
	with open('temp') as table:
		lines = table.readlines()
		for line in lines:
			if line != 'temp' and line != '\n' and line != '':
				print line
			pass
	cmd('rm temp')
Exemplo n.º 40
0
def generate_plugins():
    """ Generates plugins 
    :rtype: object
    """
    component_filename = 'component.yaml'
    plugins_dir = 'plugins'

    # 0. Connect to host
    # create plugin directory
    print(cmd('! test -f {plugins_dir} && mkdir -p {plugins_dir}'.format(plugins_dir=plugins_dir)))
    for component in components:
        # create plugin
        plugin_name = component.split(':')[-1:][0]
        plugin_path = '{plugins_dir}/{plugin_name}'.format(plugins_dir=plugins_dir, plugin_name=plugin_name)
        cmd('rm -rf {plugin_path}'.format(plugin_path=plugin_path))
        cmd('fpb --create {plugin_path}'.format(plugin_path=plugin_path))

        # fill component data
        component_content = component_tpl.format(plugin_name,
                                                 "label for " + plugin_name,
                                                 "description for " + plugin_name)
        cmd('echo "{component_content}" > {plugin_path}/{component_filename}'.format(
            component_content=component_content,
            plugin_path=plugin_path,
            component_filename=component_filename))

        # build plugin 
        print(cmd('fpb --build {plugin_path}'.format(plugin_path=plugin_path)))
Exemplo n.º 41
0
def getDisciplinePages():
	""" Return a dict {DisciplineName:URL} of URLs, each one corresponding to one Discipline """
	
	answer = {}
	cmd("cd /home/ashwin/workspace/CourseCalendar/scrapy/regcal/regcal/spiders/")
	cmd("scrapy crawl regcal --set FEED_URI=items.json --set FEED_FORMAT=json")
	
	f = open("/home/ashwin/workspace/CourseCalendar/scrapy/regcal/regcal/spiders/items.json")
	j = ' '.join([line.strip() for line in f])
	f.close()
	son = json.loads(j)
	L = [dict((str(k), [str(i) for i in d[k]]) for k in d) for d in son]
	
	for d in L:
		answer[d['discipline'][0]] = "http://www.utm.utoronto.ca/regcal/%s" %d['link'][0].replace("WEBDEP", "WEBLISTCOURSES")

	return answer
Exemplo n.º 42
0
def process():
    t1 = 1
    t2 = len(argv)-1

    try:
        while t1 <= t2:
            if str(argv[t1]) in shortcut:
                print "[s] %s shortcut detected. Killing \"%s\" with -9" % (str(shortcut[argv[t1]][:1].upper())+str(shortcut[argv[t1]][1:].lower()), str(shortcut[argv[t1]]))
                cmd("killall -9 "+str(shortcut[argv[t1]]))
                print "="*60+"\n"
                t1 += 1
            else:
                print "[i] Killing with -9: %s" % str(argv[t1])
                cmd("killall -9 "+str(argv[t1]))
                print "="*60+"\n"
                t1 += 1
    except Exception as auch:
        print "[-] Something went wrong.\n\t[*] Debugging info:\n"
        raise auch
Exemplo n.º 43
0
def profile_domain(planner, dom, domain, problem):

    print
    print "Profiling %s..." % dom

    if TYPE == OLD:
        cmd("timeout %d valgrind --tool=callgrind %s --domain %s/%s --problem %s/%s > %s.out 2>&1" % (timelimit, planner, ipc, domain, ipc, problem, dom))
    elif TYPE == NEW:
        cmd("timeout %d valgrind --tool=callgrind %s %s/%s %s/%s /dev/null > %s.out 2>&1" % (timelimit, planner, ipc, domain, ipc, problem, dom))
    else:
        assert False, "What the deuce?"

    callfile=glob.glob('callgrind.out.*')[0]
    cmd("python gprof2dot.py -f callgrind %s 2> /dev/null | dot -Tpng -o %s.png > /dev/null 2>&1" % (callfile, dom))
    cmd("rm %s" % callfile)
Exemplo n.º 44
0
def backup(fPath, buPath="~/.PyBackups/"):
	buPath += fPath.replace("/", "").replace("~", "")+strftime("/%b-%d-%H-%M")+"/"; #Gets path to put backup in
	logMsg("Backing up "+fPath+" to "+buPath, "DEBUG"); #Debugging
	logMsg("Running command "+"mkdir -p "+buPath, "DEBUG"); #Debugging
	cmd("mkdir -p "+buPath) #Creates the directory if it doesn't already exists
	logMsg("Running command "+"cp -r "+fPath+" "+buPath, "DEBUG"); #Debugging
	cmd("cp -r "+fPath+" "+buPath) #Copies the files
	cmd("touch "+addir+"budata"); #Creates the backup data file if it doesn't already exist
	open(addir+"budata", "a").write("\n"+fPath+strftime(",%a-%b-%d-%H-%M")); #Appends the backup info to the data file
Exemplo n.º 45
0
def backup(buPath):
	fPath = diropenbox("""
		Select the directory you wish to back up:
	""", "PyBackup Client");
	buPath += fPath.replace("/", "").replace("~", "")+strftime("/%b-%d-%H-%M")+"/";
	logMsg("Backing up "+fPath+" to "+buPath, "DEBUG");
	logMsg("Running command "+"mkdir -p "+buPath, "DEBUG");
	cmd("mkdir -p "+buPath)
	logMsg("Running command "+"cp -r "+fPath+" "+buPath, "DEBUG");
	cmd("cp -r "+fPath+" "+buPath)
	cmd("touch "+addir+"budata");
	open(addir+"budata", "a").write("\n"+fPath+strftime(",%a-%b-%d-%H-%M"));
Exemplo n.º 46
0
	def __init__(self, compilerpath, filec, cxfreeze=False, py2exe=False, py2app=False, mingw=False):
		super(gcc, self).__init__()
		self.c = compilerpath
		self.file = filec
		if cxfreeze == True:
			self.method = 'cxfreeze'
		elif py2exe == True:
			self.method = 'py2exe'
		elif py2app == True:
			self.method = 'py2app'
		else:
			self.method = 'shebang'
		if mingw == True:
			from os import system as cmd
			cmd('cd ./Lib/distutils')
			cmd('echo [build] >> distutils.cfg')
			cmd('echo compiler=mingw32 >> distutils.cfg')
		self.mingw = mingw
Exemplo n.º 47
0
from os import system as cmd

cmd("apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927")
cmd(
    'echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list'
)
cmd("apt-get update")
cmd("apt-get -y install mongodb-org")
cmd("apt-get -y install upstart-sysv")
Exemplo n.º 48
0
def postgres():
    with open('/etc/apt/sources.list.d/pgdg.list', 'w') as f:
        a = check_output('lsb_release -cs'.split(' ')).strip().decode('UTF-8')
        f.write('deb http://apt.postgresql.org/pub/repos/apt/ {}-pgdg main'.format(a))
    cmd('wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -')
    return 'pgadmin3'
Exemplo n.º 49
0
Arquivo: test.py Projeto: tkern0/misc
from os import system as cmd
from os import chdir as cd
from os.path import join
from os.path import normcase as nc
from os.path import normpath as np
path = "C:\\"
cd(path)
while True:
    i = input('> ')
    if i.startswith('cd ') and not i == 'cd ':
        path = nc(np(join(path, i[3:])))
        cd(path)
    else:
        cmd(i)
def clear():
    cmd("cls" if os.name == "nt" else "clear")
Exemplo n.º 51
0
 def __init__(self, master, width, height):
     super(Terminal, self).__init__(master, width=width, height=height)
     self.width = width
     self.height = height
     wid = self.winfo_id()
     cmd("xterm -into %d -geometry -sb &" % wid)
Exemplo n.º 52
0
def spotify():
    with open('/etc/apt/sources.list.d/spotify.list') as f:
        f.write('deb http://repository.spotify.com stable non-free')
    cmd('sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 \
            --recv-keys BBEBDCB318AD50EC6865090613B00F1FD2C19886')
    return 'spotify-client'
Exemplo n.º 53
0
import sys
from os import system as cmd
cmd('wget -E -H -k -p -r --convert-links '+sys.argv[1])
Exemplo n.º 54
0
def virtualbox():
    with open('/etc/apt/sources.list.d/virtualbox.list', 'w') as f:
        f.write('deb http://download.virtualbox.org/virtualbox/debian xenial contrib')
    cmd('wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -')
    return 'virtualbox-5.1'
Exemplo n.º 55
0
def couchbase():
    wget('http://packages.couchbase.com/releases/couchbase-release/couchbase-release-1.0-2-amd64.deb', 'couchbase.deb')
    cmd('sudo dpkg -i couchbase-release-1.0-2-amd64.deb')
    return 'libcouchbase-dev'
Exemplo n.º 56
0
def flux():
    cmd('sudo add-apt-repository ppa:nathan-renniewaldock/flux -y')
    return 'fluxgui'
Exemplo n.º 57
0
def vagrant():
    VAGRANT_VER = '1.8.6'
    wget('https://releases.hashicorp.com/vagrant/$VAGRANT_VER/vagrant_${VAGRANT_VER}_x86_64.deb', 'vagrant.deb')
    cmd('sudo dpkg -i {}'.format(pwd('vagrant.deb')))
    cmd('sudo pip install git+https://github.com/candidtim/vagrant-appindicator.git')
    return ''
Exemplo n.º 58
0
    def run(self):
        
        #Initialize variables
        print_frame = None
        depth_frame = np.zeros((424,512), dtype = np.uint16)
        initial = np.zeros((424,512), dtype = np.uint16)
        
        while (True):
            #Inits per cycle
            cmd('cls')                  #Clears the screen
            body_present = 0

            #Get depth frames
            if self._kinect.has_new_depth_frame():
                frame = self._kinect.get_last_depth_frame()
                frame = np.array(frame*9, dtype= np.uint16)
                frame = frame.reshape(424,512)
                depth_frame = np.array(frame)
                cv2.imshow('raw',depth_frame)
                frame = None
            
            #Check if body frames are ready and take the latest one
            if self._kinect.has_new_body_frame():
                self._bodies = self._kinect.get_last_body_frame()

            #Extract Body
            if self._bodies is not None:                
                for i in range(0, self._kinect.max_body_count):
                    body = self._bodies.bodies[i]
                    if not body.is_tracked:
                        print '::NO Body tracked'             
                        continue 
                        print ':: after_continue'
                    else:
                        #print '::Body tracked'
                        body_present = 1
                        break

            if body_present == 1:
                joints = body.joints 
                #print '::Body tracked'
                # convert joint coordinates to depth space 
                joint_points = self._kinect.body_joints_to_depth_space(joints)

                [right_hand, left_hand] = self.get_hand_coordinates(joint_points)
                [right_wrist, left_wrist] = self.get_wrist_coordinates(joint_points)
                
                d = 40

                print_frame = np.zeros(np.shape(depth_frame))
                
                if depth_frame != None: 
                    neighbour = np.array(depth_frame)
                    neighbour *= 0

                    right_hand_filtered = self.neighbourhood(depth_frame,d,right_hand)
                    left_hand_filtered = self.neighbourhood(depth_frame,d,left_hand)
                    
                    cv2.imshow('depth',depth_frame)

                    if right_hand_filtered != None:
                        right_hand_depth = right_hand_filtered[d,d] 
                        right_hand_filtered[right_hand_filtered > right_hand_depth + 1200] = 0
                        # right_hand_filtered[right_hand_filtered < right_hand_depth - 1200] = 0

                        
                        right_hand_filtered_depth_frame = self.merge(neighbour, right_hand_filtered,right_hand)                     
                        neighbour = right_hand_filtered_depth_frame

                    if left_hand_filtered != None:
                        left_hand_depth = left_hand_filtered[d,d] 
                        left_hand_filtered[left_hand_filtered > left_hand_depth + 1200] = 0
                        # left_hand_filtered[left_hand_filtered < left_hand_depth - 1200] = 0
                        
                        left_hand_filtered_depth_frame = self.merge(neighbour, left_hand_filtered,left_hand)                         
                        # ret,left_hand_filtered_depth_frame = cv2.threshold(left_hand_filtered_depth_frame,0,255,cv2.THRESH_OTSU)
                                       
                    hand_filtered = left_hand_filtered_depth_frame
                    hand_filtered_8 = np.array(hand_filtered/255, dtype = np.uint8)
                    # hand_filtered += right_hand_filtered_depth_frame

                    cv2.imshow('final',hand_filtered)
                    cv2.imshow('8-bit', hand_filtered_8)


                    right = np.array(right_hand_filtered/255, dtype = np.uint8)
                    ret, right = cv2.threshold(right,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)

                    img1,contours1, hierarchy1 = cv2.findContours(right,cv2.RETR_CCOMP,cv2.CHAIN_APPROX_SIMPLE)
                    cnt = contours1[self.max_area_contour(contours1)]
                    hull = cv2.convexHull(cnt,returnPoints = False)
                    defects = cv2.convexityDefects(cnt,hull)
                    drawing = np.zeros(right_hand_filtered.shape,np.uint8)
                    drawing = cv2.cvtColor(drawing,cv2.COLOR_GRAY2RGB)
                    for i in range(defects.shape[0]):
                        s,e,f,d = defects[i,0]
                        start = tuple(cnt[s][0])
                        end = tuple(cnt[e][0])
                        far = tuple(cnt[f][0])
                        cv2.line(drawing,start,end,[0,255,0],2)
                        cv2.circle(drawing,far,5,[0,0,255],-1)
                    drawing = cv2.drawContours(drawing,[cnt],-1,150,1)
                    cv2.imshow('contours1',drawing)

            

            if cv2.waitKey(1) & 0xFF == ord('q'):
                break

        # Close our Kinect sensor, close the window and quit.
        self._kinect.close()