Esempio n. 1
0
File: test_acl.py Progetto: kraj/ltp
def test_nfs_getfacl():
	# mesures sur le getfacl
	test = RandomGen()

	path = '/mnt/nfs/test-acl' # NFS mounted directory
	u = subprocess.getoutput('rm ' + path + "/*")	# clean directory
	print("test acl getfacl\n")
	f = open('/tmp/acl-result-getfacl','w')
	for i in range(37):

		test.getUserList()
		testfile = 'testfile' + str(i)

		u = subprocess.getoutput('touch ' + path + "/" + testfile)
		print("setfacl " + str(i) + " " + u)
		for j in range(i):
			user = test.uList.pop()
			mode = test.createRandomMode()
			u = subprocess.getoutput('setfacl -m u:' + user + ':' + mode + " " + path + "/" + testfile)

		t1=time.time()
		u = subprocess.getoutput('getfacl ' + path + "/" + testfile)
		print("getfacl - " + str(i) + u + "\n")
		t2=time.time()
		f.write(str(i) + "\t" + str(t2-t1)+"\n")
		f.close()
Esempio n. 2
0
File: test_acl.py Progetto: kraj/ltp
def test_acl_default(path):

# set default acl on the test directory
	u = subprocess.getoutput('mkdir ' + path + "/" + testdir)
	u = subprocess.getoutput('getfacl ' + path + "/" + testdir)
	acl=[]
	for i in range (len(splitedresult)-1):
		splitedline = splitedresult[i].split('::')
		name = splitedline[0]
		entry = splitedline[1]
		acl.append(name,entry)
# create a file in this directory
	u = subprocess.getoutput('touch ' + path + "/" + testdir + testfile)
# get the file's ACL and verify
	u = subprocess.getoutput('getfacl ' + path + "/" + testdir + testfile)
	splitedresult = u.split('\n')
	acl2=[]
	for i in range (len(splitedresult)-1):
		splitedline = splitedresult[i].split('::')
		name = splitedline[0]
		entry = splitedline[1]
		acl2.append(name,entry)

	result_final = True
	while i < len(acl2):
		result = False
		while j < len(acl2) and result == False:
			if acl2[i] == acl[j]:
				result = True
		if result == False:
			result_final = False
def restruct_linux():
    qmake = sys.argv[3]
    # Copy the entire directory
    for d in ['bin', 'lib', 'libexec', 'share']:
        shutil.copytree(os.path.join(app_bundle, d), os.path.join(target_path, d), symlinks=True)

    # Copy Qt libs
    qtlibs_dir = subprocess.getoutput('%s -query QT_INSTALL_LIBS' % qmake).strip()
    for lib in ['Core', 'Gui', 'Widgets', 'Concurrent', 'Network', 'PrintSupport',
                'Qml', 'Quick', 'QuickWidgets', 'Xml', 'Svg', 'XcbQpa', 'Sql']:
        shutil.copy(os.path.join(qtlibs_dir, 'libQt5%s.so.5'%lib), lib_dir)

    # Copy Qt plugins
    qtplugins_dir = subprocess.getoutput('%s -query QT_INSTALL_PLUGINS' % qmake).strip()
    os.makedirs(plugins_dir)
    for plugin in ['bearer', 'designer', 'iconengines', 'imageformats',
                   'platforms', 'sqldrivers', 'xcbglintegrations']:
        shutil.copytree(os.path.join(qtplugins_dir, plugin), os.path.join(plugins_dir, plugin))
    # Copy QtQuick modules
    qtqml_dir = subprocess.getoutput('%s -query QT_INSTALL_QML' % qmake).strip()
    shutil.copytree(qtqml_dir, qml_dir)
    # Fix qt.conf
    open(os.path.join(bin_dir, 'qt.conf'), 'w').write('[Paths]\nPrefix = ..\n')
    open(os.path.join(libexec_dir, 'qtcreator', 'qt.conf'), 'w').write('[Paths]\nPrefix = ../..\n')
    # Fix rpath of qtcreator and executibles under libexec
    cmd = "chrpath -r '$ORIGIN/../lib/qtcreator:$ORIGIN/../lib:' " + os.path.join(bin_dir, 'qtcreator')
    os.system(cmd)
    for f in os.listdir(os.path.join(libexec_dir, 'qtcreator')):
        cmd = "chrpath -r '$ORIGIN/../../lib/qtcreator:$ORIGIN/../../lib:' " + os.path.join(libexec_dir, 'qtcreator', f)
        os.system(cmd)
Esempio n. 4
0
def main():
    print('Strated ---------------------')

    # execute(['ls', '-ls'])

    # proc = subprocess.Popen(['ls -lsa'], stdout = subprocess.PIPE, shell = True)
    # (out, err) = proc.communicate()
    # proc_status = proc.wait()
    # print("Command exit status: " + str(proc_status))
    # print("Command output: " + str(out))

    # output = subprocess.check_output('ls -ls', shell = True)
    # print(output)

    ip = '178.62.18.112'
    cmd = 'ssh-keygen -f ~/.ssh/known_hosts -R ' + ip
    print('CMD [' + cmd + ']')
    stdoutdata = subprocess.getoutput(cmd)
    print('------- OUTPUT START --------')
    print(stdoutdata)
    print('======= OUTPUT END   ========')

    cmd = 'echo -e \"Host ${myvmip}\n\tStrictHostKeyChecking no\n\" >> ~/.ssh/config'
    print('CMD [' + cmd + ']')
    stdoutdata = subprocess.getoutput(cmd)
    print('------- OUTPUT START --------')
    print(stdoutdata)
    print('======= OUTPUT END   ========')

    # s = pxssh.pxssh()
    # s.login()
    print('Finished --------------------')
Esempio n. 5
0
def library_install_objdump(path, level):
    if path in skip_libs or path in done:
        return

    if level > 0:
        lib = find_dll(path)
        if lib == "":  # not found
            skip_libs.append(path)
            print("Not found: " + path)
            return
        print(lib)
        subprocess.getoutput("cp " + lib + " " + build_path)

    else:
        print("Processing target " + path)
        lib = path

    done.append(path)

    command = objdump_path + " -p " + lib + " | grep -o ': .*\.dll$'"
    res = subprocess.getstatusoutput(command)
    if (res[0] > 0):
        print("Error: objdump failed with " + lib)
    else:
        dlls = subprocess.getoutput(command).split("\n")
        for line in dlls:
            dll = (line.split(": "))[1]
            if dll not in done and dll not in skip_libs:
                level += 1
                library_install_objdump(dll, level)
Esempio n. 6
0
def provision_db_container(drucker):
    """Provision database container"""
    if subprocess.getoutput("docker ps -a | grep -o %s" % (drucker.vars.DB_CONTAINER)):
        print(
            colorful.green("%s container already exists." % (drucker.vars.DB_CONTAINER))
        )

        if subprocess.getoutput("docker ps | grep -o %s" % (drucker.vars.DB_CONTAINER)):
            o.run_db_orchestration(drucker)
        else:
            print(
                colorful.white_on_blue(
                    "Starting %s container..." % (drucker.vars.DB_CONTAINER)
                )
            )
            start_db_container(drucker)
            o.run_db_orchestration(drucker)
    else:
        if subprocess.getoutput(
            "docker images | awk '{print $1\":\"$2}' | grep %s"
            % (drucker.vars.DB_IMAGE)
        ):
            print(
                colorful.green(
                    "%s custom image already exists." % (drucker.vars.DB_IMAGE)
                )
            )
            create_db_container(drucker)
        else:
            create_base2db_container(drucker)
            create_db_image(drucker)
    def test_permission_checks(self):
        noWriteToTv = r'python3 ../run_torrent_extract.r.py -d -t /root "' + self.path + self.downloads[
            0][0] + '"'
        noWriteToFilm = r'python3 ../run_torrent_extractor.py -d -f /root "' + self.path + self.downloads[
            0][0] + '"'
        noWriteToLog = r'python3 ../run_torrent_extractor.py -d -l /root -f /media/axel/test/films "' + self.path + self.downloads[
            0][0] + '"'
        torrentNotExisting = r'python3 ../run_torrent_extractor.py -d "Mumbo.Jumbo.S99E32.The.Episode.That.Never.Was-4K.H265.mkv"'

        try:
            output = subprocess.getoutput(noWriteToTv)
            self.assertEqual(
                output, "[CRITICAL] No write permission to /root, exiting.")
            output = subprocess.getoutput(noWriteToFilm)
            self.assertEqual(
                output, "[CRITICAL] No write permission to /root, exiting.")
            output = subprocess.getoutput(noWriteToLog)
            self.assertTrue(
                "[WARNING] No write permission to /root, no log file will be written."
                in output)
            output = subprocess.getoutput(torrentNotExisting)
            self.assertEqual(
                output,
                "[CRITICAL] Mumbo.Jumbo.S99E32.The.Episode.That.Never.Was-4K.H265.mkv does not exist, exiting."
            )

        except AssertionError as e:
            self.errors.append("Did not detect write permission error: " +
                               output)
def distribution_check():
    ret = {
            "key": "Linux distribution",
            "cn_desc": "Linux 发行版",
            }
    if os.path.exists("/etc/redhat-release"):
        release = getoutput("cat /etc/redhat-release").strip().lower()
        pass_check = False
        for r in REQUIRED_RELEASE:
            if r in release:
                pass_check = True
        if pass_check:
            ret.update({
                "value": release,
                "pass_standalone": True,
                "pass_cluster": True,
                "fail_reason": ""
                })
        else:
            ret.update({
                "value": release,
                "pass_standalone": False,
                "pass_cluster": False,
                "fail_reason": "仅支持以下发行版: %s" % ",".join(REQUIRED_RELEASE),
                })

        pass
    else:
        ret.update({
                "value": "[ " + getoutput("lsb_release -a") + "] not CentOS",
                "pass_standalone": False,
                "pass_cluster": False,
                "fail_reason": "非 CentOS 系统"
                })
    return ret
def write_report(user, time, hostname, distro, hw, mem, cpu, disk, outfile):
    lines = []
    sp = "---------------------------------------"
    lines.append("Sensors Analytics installation evironment check report")
    lines.append(sp)
    lines.append("user:              "******"value"))
    lines.append("test date:         " + time.get("value"))
    lines.append("hostname -f:       " + hostname.get("value"))
    lines.append("distro:            " + distro.get("value"))
    lines.append("hardware platform: " + hw.get("value"))
    lines.append("memory:            " + mem.get("value"))
    lines.append(sp)
    lines.append("lscpu:")
    lines.append(cpu['lscpu'])
    lines.append(sp)
    lines.append("/proc/cpuinfo:")
    lines.append(cpu['proc_cpuinfo'])
    lines.append(sp)
    lines.append("df -h")
    lines.append(getoutput("df -h"))
    lines.append(sp)
    lines.append("mount")
    lines.append(getoutput("mount"))
    lines.append(sp)
    lines.append("disk detail:")
    import io
    ppout = io.StringIO()
    import pprint
    pprint.pprint(disk, stream=ppout)
    lines.append(ppout.getvalue())

    for l in lines:
        print(l, file=outfile)
def cpu_check():
    """
    TODO: split processor num / ssse3
    """
    ret = {
            "key": "cpu",
            "cn_desc": "cpu",
            }
    output = getoutput('cat /proc/cpuinfo').splitlines()
    # 某行类似processor : 3
    lines = [l for l in output if l.strip() and l.split()[0] == 'processor']
    cpu_num = len(lines)
    fail_standalone = False
    fail_cluster = False
    fail_reason = ""
    if cpu_num < CLUSTER_SYS_REQ['MIN_CPU_CORE_NUM']:
        fail_cluster |= True
        fail_reason = "集群版最低CPU核数:%d" % CLUSTER_SYS_REQ['MIN_CPU_CORE_NUM']
    if cpu_num < STANDALONE_SYS_REQ['MIN_CPU_CORE_NUM']:
        fail_standalone = True
        fail_reason = fail_reason + ", 单机版最低CPU核数:%d" % STANDALONE_SYS_REQ['MIN_CPU_CORE_NUM']
    support_ssse3 = len([l for l in output if 'flags' in l and 'ssse3' in l]) > 0
    fail_cluster |= not support_ssse3
    if not support_ssse3:
        fail_reason = fail_reason + ", 集群版要求CPU支持ssse3指令集"
    ret.update({
        "value": "processor num: %d, support ssse3: %r" % (cpu_num, support_ssse3),
        "pass_standalone": not fail_standalone,
        "pass_cluster": not fail_cluster,
        "fail_reason": fail_reason,
        "lscpu": getoutput("lscpu"),
        "proc_cpuinfo": getoutput("cat /proc/cpuinfo"),
        })
    return ret
Esempio n. 11
0
def run(msg):
    header = 'Hi! I\'m *#BOT_FIRSTNAME*'
    header += '\nNice to meet you.'

    help = '\nUse ' + config['command_start'] + 'help for a list of commands.'
    license = '\n*#BOT_FIRSTNAME* uses *Polaris* which is licensed under the *GPLv2*.'
    source = '\n[Source Code on Github](https://github.com/luksireiku/polaris)'
    channel = '\nChannel: @PolarisChannel'
    group = '\nJoin [Society of Polaris](https://telegram.me/joinchat/B09roADwf_8-9zMfxniOpA)!'
    stats = '\nUsers: {0}\nGroups: {1}'.format(len(users), len(groups))

    if get_command(msg['text']) == 'about':
        about = header + '\n' + license + source + '\n' + stats + '\n' + channel + group
        about = tag_replace(about, msg)

        send_message(msg['chat']['id'], about, disable_web_page_preview=True, parse_mode="Markdown")

    elif get_command(msg['text']) == 'system':
        running = '\n*Running on*:\n'
        running += '\t*System*: {0}\n'.format(subprocess.getoutput('head -n1 /etc/issue | cut -d " " -f -3'))
        running += '\t*Kernel*: {0}\n'.format(subprocess.getoutput('uname -rs'))
        running += '\t*CPU*: {0}\n'.format(subprocess.getoutput('cat /proc/cpuinfo | grep "model name" | tr -s " " | cut -d " " -f 3-'))
        running += '\t*RAM*: {0}MB ({1}% used)\n'.format(int(psutil.virtual_memory()[0] / 1000 / 1000), psutil.virtual_memory()[2])
        running += '\t*Python*: {0} ({1})\n'.format(str(platform.python_version()), str(platform.python_compiler()))
        running += '\t*Time*: {0}\n'.format(time.strftime("%c"))
        running += '\t*Uptime*: {0}\n'.format(subprocess.getoutput('uptime -p'))

        send_message(msg['chat']['id'], running, parse_mode="Markdown")

    else:
        start = tag_replace(header, msg)

        send_message(msg['chat']['id'], start, parse_mode="Markdown")
Esempio n. 12
0
def show_sys_info(yn):
    """Showing some info, plan to add more. Currently shows:
    Number of Cores, CPU"""

    print("_".center(80, '_')) #Filling screen with line
    print("Printing System Info".center(80,'.')+ '\n')
    cpu_proc = subprocess.getoutput("lscpu | grep 'Model name:'")
    cpu_name = " ".join((cpu_proc.split()[2:]))
    cores_proc = subprocess.getoutput("lscpu | grep 'CPU(s):'")
    cores = cores_proc.split()[1]
    arch = subprocess.getoutput("uname -m")


    mem_free_proc = subprocess.getoutput("free -h")
    temp = mem_free_proc.split()
    total_mem = temp[7]
    used_mem = temp[8]
    free_mem = temp[9]
    cached_mem = temp[11]

    print_info("CPU:", cpu_name)
    print_info("NUM CORES:", cores)
    print_info("ARCHITECTURE:", arch)
    print_seperator()

    print("MEMORY USAGE:".center(80))
    print_info("TOTAL MEMORY:", total_mem)
    print_info("USED MEMORY:", used_mem)
    print_info("CACHED MEMORY:", cached_mem)
    print_info("FREE MEMORY:", free_mem)
    print_seperator()

    show_gui_info()
    return
Esempio n. 13
0
    def scamper_call(self,IP_name,arguments):
        if arguments=='':
            whole=subprocess.getoutput('scamper -i '+IP_name)
        else:
            arguments='"trace '+arguments+' '+IP_name+'"'
            try:
                whole=subprocess.getoutput('scamper -I '+arguments)
            except:
                print('Scamper failed to traceroute. Exiting.')
                exit(0)

        splitted=whole.split('\n')
        rows=len(splitted)-1
        route=[0 for x in range(0,rows)]
        mytime=['-' for x in range(0,rows)]

        for i in range (1,rows+1):
            pos=0
            temp=splitted[i].split(' ')
            while temp[pos]=='':
                pos=pos+1
            if i>0:
                route[i-1]=temp[pos+2]
            
                if len(temp)>pos+4:
                    mytime[i-1]=temp[pos+4]+' '+temp[pos+5]
            i=i+1

        return [route,mytime]
Esempio n. 14
0
def run_pbs_jobs(c, config_file, strategies_file, subject_list_file, p_name):



    import subprocess
    from time import strftime


    try:
        sublist = yaml.load(open(os.path.realpath(subject_list_file), 'r'))
    except:
        raise Exception ("Subject list is not in proper YAML format. Please check your file")
    
    temp_files_dir = os.path.join(os.getcwd(), 'cluster_temp_files')
    shell = subprocess.getoutput('echo $SHELL')
    subject_bash_file = os.path.join(temp_files_dir, 'submit_%s.pbs' % str(strftime("%Y_%m_%d_%H_%M_%S")))
    f = open(subject_bash_file, 'w')
    print('#! %s' % shell, file=f)
    print('#PBS -S %s' % shell, file=f)
    print('#PBS -V', file=f)
    print('#PBS -t 1-%d' % len(sublist), file=f)
    print('#PBS -q %s' % c.queue, file=f)
    print('#PBS -l nodes=1:ppn=%d' % c.numCoresPerSubject, file=f)
    print('#PBS -e %s' % os.path.join(temp_files_dir, 'c-pac_%s.err' % str(strftime("%Y_%m_%d_%H_%M_%S"))), file=f)
    print('#PBS -o %s' % os.path.join(temp_files_dir, 'c-pac_%s.out' % str(strftime("%Y_%m_%d_%H_%M_%S"))), file=f)
    print('source ~/.bashrc', file=f)

    print("python -c \"import CPAC; CPAC.pipeline.cpac_pipeline.run(\\\"%s\\\",\\\"%s\\\",\\\"${PBS_ARRAYID}\\\",\\\"%s\\\", \\\"%s\\\" , \\\"%s\\\", \\\"%s\\\", \\\"%s\\\") \" " % (str(config_file), \
        subject_list_file, strategies_file, c.maskSpecificationFile, c.roiSpecificationFile, c.templateSpecificationFile, p_name), file=f)
#    print >>f, "python -c \"import CPAC; CPAC.pipeline.cpac_pipeline.py -c %s -s %s -indx ${PBS_ARRAYID} -strategies %s \" " %(str(config_file), subject_list_file, strategies_file)
    #print >>f, "python CPAC.pipeline.cpac_pipeline.py -c ", str(config_file), "-s ", subject_list_file, " -indx ${PBS_ARRAYID} -strategies ", strategies_file
    f.close()

    subprocess.getoutput('chmod +x %s' % subject_bash_file )
Esempio n. 15
0
    def find(self, pkg, chkdistro, filelookup=True):
        _pkg = ''.join([x for x in pkg.strip().split(None,1)[0] if x.isalnum() or x in '.-_+/'])
        distro = ''
        if len(pkg.strip().split()) > 1:
            distro = ''.join([x for x in pkg.strip().split(None,2)[1] if x.isalnum() or x in '.-_+'])
        if not distro:
            distro = chkdistro
        if distro not in self.distros:
            return "%s is not a valid distribution: %s" % (distro, ", ".join(self.distros))
        pkg = _pkg

        data = subprocess.getoutput(self.aptcommand % (distro, distro, distro, distro, 'search -n', pkg))
        if not data:
            if filelookup:
                data = subprocess.getoutput(self.aptfilecommand % (distro, distro, pkg)).split()
                if data:
                    if data[0] == 'sh:': # apt-file isn't installed
                      self.log.error("PackageInfo/packages: apt-file is not installed")
                      return "Please use http://packages.ubuntu.com/ to search for files"
                    if data[0] == 'E:': # No files in the cache dir
                      self.log.error("PackageInfo/packages: Please run the 'update_apt_file' script")
                      return "Cache out of date, please contact the administrator"
                    if data[0] == "Use" and data[1] == "of":
                        url = "http://packages.ubuntu.com/search?searchon=contents&keywords=%s&mode=&suite=%s&arch=any" % (urllib.parse.quote(pkg), distro)
                        return url
                    if len(data) > 10:
                        return "File %s found in %s (and %d others) http://packages.ubuntu.com/search?searchon=contents&keywords=%s&mode=&suite=%s&arch=any" % (pkg, ', '.join(data[:10]), len(data)-10, urllib.parse.quote(pkg), distro)
                    return "File %s found in %s" % (pkg, ', '.join(data))
                return 'Package/file %s does not exist in %s' % (pkg, distro)
            return "No packages matching '%s' could be found" % pkg
        pkgs = [x.split()[0] for x in data.split('\n')]
        if len(pkgs) > 10:
            return "Found: %s (and %d others) http://packages.ubuntu.com/search?keywords=%s&searchon=names&suite=%s&section=all" % (', '.join(pkgs[:10]), len(pkgs)-10, urllib.parse.quote(pkg), distro)
        else:
            return "Found: %s" % ', '.join(pkgs[:5])
Esempio n. 16
0
 def _learn(self, irc, msg, channel, text, probability):
     """Internal method for learning phrases."""
     
     if os.path.exists(self._getBrainDirectoryForChannel(channel)):
         # Does this channel have a directory for the brain file stored and does this file exist?
         
         text = self._cleanText(text)
         
         if text and len(text) > 1 and not text.isspace():
     
             self.log.debug("Learning: {0}".format(text))
             cobeBrain = Brain(self._getBrainDirectoryForChannel(channel))
             cobeBrain.learn(text)
             
             if random.randint(0, 10000) <= probability:
                 self._reply(irc, msg, channel, text)
             
     else: # Nope, let's make it!
                     
         subprocess.getoutput('{0} {1}'.format(self._doCommand(channel), 'init'))
         
         text = self._cleanText(text)
         
         if text and len(text) > 1 and not text.isspace():
     
             self.log.debug("Learning: {0}".format(text))
             cobeBrain = Brain(self._getBrainDirectoryForChannel(channel))
             cobeBrain.learn(text)
             
             if random.randint(0, 10000) <= probability:
                 self._reply(irc, msg, channel, text)
Esempio n. 17
0
def commit():
    changes = subprocess.getoutput('git status -s')
    if not changes:
        return
    subprocess.call(['git', 'add', '--all', '.'])
    commitMsg = subprocess.getoutput('git status -s')
    subprocess.call(['git', 'commit', '-m', "{0}".format(commitMsg)])
Esempio n. 18
0
def menu():
	requestMenu = subprocess.getoutput("echo `zenity --list --title='PTTP' --text='What type of request do you want to make?' --column='Request type' 'GET' 'POST'`")
	requestMenu = requestMenu.split("\n")
	requestMenu = requestMenu[len(requestMenu) - 1]

	if requestMenu == "GET":
		#Do a GET request
		getMenu = subprocess.getoutput("echo `zenity --list --title='PTTP' --text='Authentication/response:' --column='Option' 'No authentication' 'Basic authentication' 'No authentication (plain text)' 'Basic authentication (plain text)'`")
		getMenu = getMenu.split("\n")
		getMenu = getMenu[len(getMenu) - 1]
		try:
			get(getMenu)
		except(urllib.error.HTTPError, urllib.error.URLError) as error:
			os.system("zenity --error --title='PTTP' --text='"+format(error)+"'")
		except:
			os.system("zenity --error --title='PTTP' --text='Oops! There was an error in your request.'")
	elif requestMenu == "POST":
		#Do a POST request
		postMenu = subprocess.getoutput("echo `zenity --list --title='PTTP' --text='Authentication/response:' --column='Option' 'No authentication' 'Basic authentication' 'No authentication (plain text)' 'Basic authentication (plain text)'`")
		postMenu = postMenu.split("\n")
		postMenu = postMenu[len(postMenu) - 1]
		try:
			post(postMenu)
		except(urllib.error.HTTPError, urllib.error.URLError) as error:
			os.system("zenity --error --title='PTTP' --text='"+format(error)+"'")
		except:
			os.system("zenity --error --title='PTTP' --text='Oops! There was an error in your request.'")
	else:
		sys.exit()
Esempio n. 19
0
def check_mdaq_install():
    global mdaq_dir, mdaq_bin, mdaq_enabled

    # check paths
    mdaq_dir, mdaq_bin = mdaq_sys['path'], mdaq_sys['bin']
    if mdaq_cfg:
        if not mdaq_dir: mdaq_dir = getoutput("%s --execdir"%(mdaq_cfg))
        if not mdaq_bin: mdaq_bin = getoutput("%s --bindir"%(mdaq_cfg))
    elif 'MIDASSYS' in os.environ:
        if not mdaq_dir: mdaq_dir = os.environ['MIDASSYS']
        if not mdaq_bin: mdaq_bin = os.path.join(os.environ['MIDASSYS'],'bin')
    else:
        print("Either enviroment \"MIDASSYS\" defined nor mdaq-config found!")
        print("You should check your MIDAS package installation!")
        print(mdaq_errmsg)
        mdaq_enabled = False
    if not os.path.isdir(mdaq_bin) or not os.path.isdir(mdaq_dir):
        print(mdaq_errmsg)
        mdaq_enabled = False

    # check MIDASSYS environment
    if 'MIDASSYS' not in os.environ:
        os.environ.setdefault("MIDASSYS", mdaq_dir)
    # update "PATH" environment
    if mdaq_bin not in os.environ['PATH'].split(':'):
        os.environ['PATH']=':'.join([mdaq_bin, os.environ['PATH']])
Esempio n. 20
0
  def GetProtoRuleFormattedData(cls, rule_data, out_type):
    """Get the formatted proto dependency info for the output type.

    Args:
      rule_data: dict: The rule data for the proto rule.
      out_type: string: The type for which the proto data is to be generated.

    Return:
      dict: Corresponding rules generated for the out_type.
    """
    srcs = rule_data.get('src', set())

    protobuf_base_dir = cls.GetProtoBufBaseDir();
    out = {}
    if out_type.find('cc_') == 0 :  # Generated cc rule.
      pkg_config_cmd = ('export PKG_CONFIG_PATH=%s; '
          'pkg-config --define-variable=prefix=%s protobuf' %
          (os.path.join(protobuf_base_dir, 'lib/pkgconfig'), protobuf_base_dir))

      out['src'] = set([ cls.__GetOutFileName(x, '.pb.cc') for x in srcs ])
      out['hdr'] = set([ cls.__GetOutFileName(x, '.pb.h') for x in srcs ])
      out['flag'] = set(subprocess.getoutput(pkg_config_cmd + ' --cflags').split())
      out['link'] = set(subprocess.getoutput(pkg_config_cmd + ' --libs').split())
    else:
      TermColor.Error('Unsupported referrer type %s' % out_type)

    return out
Esempio n. 21
0
def qa_build(host, build, arch_desc, subarch, head, target):
    success = False
    print("Performing remote QA build on %s for %s %s %s %s (%s)" % (host, build, arch_desc, subarch, head, target))
    build_dir = datetime.datetime.now().strftime("%Y-%m-%d") + "-" + head
    exists = (
        subprocess.getoutput(
            "ssh %s '[ -e /home/mirror/funtoo/%s/%s/%s/" % (host, build, arch_desc, subarch)
            + build_dir
            + "/status ] && echo yep || echo nope'"
        )
        == "yep"
    )
    if not exists:
        status = subprocess.call(
            ["/usr/bin/ssh", host, "/root/metro/scripts/ezbuild.sh", build, arch_desc, subarch, target, build_dir]
        )
        if status:
            print("ezbuild.sh completed with errors.")
    success = (
        subprocess.getoutput(
            "ssh %s cat /home/mirror/funtoo/%s/%s/%s/" % (host, build, arch_desc, subarch) + build_dir + "/status"
        )
        == "ok"
    )
    if success:
        print("Build successful.")
    else:
        print("Build FAILED.")
    return success
Esempio n. 22
0
def detect_verify_code_by_java(image_path, broker):
    jars = {
        'ht': ('getcode_jdk1.5.jar', ''),
        'yjb': ('yjb_verify_code.jar', 'guojin')
    }
    verify_code_tool, param = jars[broker]
    # 检查 java 环境,若有则调用 jar 包处理 (感谢空中园的贡献)
    # noinspection PyGlobalUndefined
    if six.PY2:
        if sys.platform == 'win32':
            from subprocess import PIPE, Popen, STDOUT

            def getoutput(cmd, input=None, cwd=None, env=None):
                pipe = Popen(cmd, shell=True, cwd=cwd, env=env, stdout=PIPE, stderr=STDOUT)
                (output, err_out) = pipe.communicate(input=input)
                return output.decode().rstrip('\r\n')
        else:
            import commands
            getoutput = commands.getoutput
    else:
        from subprocess import getoutput
    out_put = getoutput('java -version')
    log.debug('java detect result: %s' % out_put)
    if out_put.find('java version') != -1 or out_put.find('openjdk') != -1:
        tool_path = os.path.join(os.path.dirname(__file__), 'thirdlibrary', verify_code_tool)
        out_put = getoutput('java -jar "{}" {} {}'.format(tool_path, param, image_path))
        log.debug('recognize output: %s' % out_put)
        verify_code_start = -4
        return out_put[verify_code_start:]
Esempio n. 23
0
def deployQtLibraries():
    libs = ['Core', 'Gui', 'Widgets', 'Concurrent', 'Network', 'PrintSupport', 'Script',
            'Qml', 'Quick', 'QuickWidgets', 'QuickControls2', 'QuickTemplates2', 'QuickParticles',
            'Xml', 'Svg', 'Sql', 'Help']
    qtlibs_dir = subprocess.getoutput('%s -query QT_INSTALL_LIBS' % qmake).strip()
    dst_dir = lib_dir
    lib_pattern = 'libQt5%s.so*'
    ignore_pattern = None

    if platform.system() == 'Darwin':
        lib_pattern = 'Qt%s.framework'
        ignore_pattern = shutil.ignore_patterns('Headers', '*_debug', '*.prl')
    elif platform.system() == 'Windows':
        qtlibs_dir = subprocess.getoutput('%s -query QT_INSTALL_BINS' % qmake).strip()
        dst_dir = bin_dir
        lib_pattern = 'Qt5%s.dll'
    elif platform.system() == 'Linux':
        libs += ['XcbQpa']

    if not os.path.exists(dst_dir):
        os.makedirs(dst_dir)

    for lib in libs:
        for file in glob.glob(os.path.join(qtlibs_dir, lib_pattern%lib)):
            smartCopy(file, dst_dir, follow_symlinks=False, ignore=ignore_pattern)

    if platform.system() == 'Windows':
        for lib in ['libEGL.dll', 'libGLESv2.dll']:
            smartCopy(os.path.join(qtlibs_dir, lib), dst_dir)
Esempio n. 24
0
    def test_run(self):
        self.maxDiff = None
        # begin test
        # jack install the *hookman* by pip
        # he run his cmd
        help_text = subprocess.getoutput('hookman')


        # help list
        self.assertIn('-h', help_text)
        self.assertIn('--version', help_text)
        self.assertIn('--stop', help_text)
        self.assertIn('--run', help_text)
        self.assertIn('--pidfile', help_text)
        self.assertIn('--logfile', help_text)
        self.assertIn('--projectdir', help_text)

        # he try -v
        version_info = subprocess.getoutput('hookman --version')

        self.assertEqual('0.1.2', version_info)

        # he let it run

        start_run = subprocess.getoutput('hookman --run -d')
        self.assertEqual('hookman running background', start_run)
        import time
        time.sleep(2)

        ## he do a little test
        # he try ping
        result = subprocess.getoutput('curl -X POST --header "X-GitHub-Event: ping" http://localhost:3610/')

        ## he expect a pong back
        self.assertIn('pong', result)
def tmux_layout():
    """Layout for gdb-dashboard using tmux panes"""
    # Bug? Cursor (in the terminal) is gone in any tmux pane after this function.
    panes_tty = subprocess.getoutput(["tmux lsp -F'#{pane_tty}'"]).split('\n')
    panes_id = subprocess.getoutput(["tmux lsp -F'#{pane_id}'"]).split('\n')
    print("panes_tty =", panes_tty)
    if len(panes_tty) == 2:
        # Put the outout in the right pane, and enable history and stacklocals
        gdb.execute("dashboard -layout !stacklocals stack history !threads source")
        # gdb.execute("dashboard -output " + panes_tty[1])
        # gdb.execute("dashboard stacklocals -output " + panes_tty[1])
        right_tty = panes_tty[1]
        gdb.execute("dashboard stack -output "   + right_tty)
        gdb.execute("dashboard history -output " + right_tty)
        gdb.execute("dashboard source -output "  + right_tty)
    if len(panes_tty) == 3:
        # NOTE: Execute tmux_split_gdb (from ~/.tmux_utils)
        gdb.execute("dashboard -layout stacklocals stack history !threads source")
        # gdb.execute("dashboard -output " + panes_tty[1])
        right_tty = panes_tty[2]
        up_index = 0
        up_tty = panes_tty[up_index]
        gdb.execute("dashboard stacklocals -output " + right_tty)
        gdb.execute("dashboard stack -output "       + right_tty)
        gdb.execute("dashboard history -output "     + right_tty)
        gdb.execute("dashboard source -output "      + up_tty)
        pane_source_height = subprocess.getoutput(["tmux lsp -F'#{pane_height}'"]).split('\n')[up_index]
        gdb.execute("dashboard source -style context " + str(int(int(pane_source_height)/2.1)))
Esempio n. 26
0
 def _resolution(self):
     width=0
     heigth=0
     if(SystemInformations._platform(self) != "Windows"):            
         resolution = str(subprocess.getoutput("xrandr | grep connected"))
         resolution = re.sub("[a-z]*-[0-9]*", "", resolution)
         resolution = re.sub("\).*", "", resolution)
         resolution = re.sub("\+.* ", "", resolution)
         resolution = re.sub("[^0-9^\n]*", "", resolution)
         parseResolution = resolution.split("\n")
         for x in range(0, len(parseResolution)):
             if(width != 0):
                 if(parseResolution[x][0:4] != ""):
                     width=width+int(parseResolution[x][0:4])
             else:
                 if(parseResolution[x][0:4] != ""):
                     width=int(parseResolution[x][0:4])
                 
             if(heigth != 0):
                 if(parseResolution[x][4:9] != ""):
                     if(heigth < int(parseResolution[x][4:9])):
                         heigth = int(parseResolution[x][4:9])
             else:
                 if(parseResolution[x][4:9] != ""):
                     heigth=int(parseResolution[x][4:9])            
         
     else:
         resolution=re.sub("\n","",subprocess.getoutput("wmic path Win32_VideoController  get CurrentHorizontalResolution,CurrentVerticalResolution"))
         resolution=re.sub(" *","",resolution)
         resolution=re.sub("CurrentHorizontalResolution","",resolution)
         resolution=re.sub("CurrentVerticalResolution","",resolution)
         width=int(resolution[0:4])
         heigth=int(resolution[4:8])            
     totalResolution = str(width)+"x"+str(heigth)
     return totalResolution
Esempio n. 27
0
def create_db_image(drucker):
    """Create database image from database container"""
    print(
        colorful.white_on_blue(
            "Committing %s image from %s container..."
            % (drucker.vars.DB_IMAGE, drucker.vars.DB_CONTAINER)
        )
    )

    subprocess.run(
        'docker commit -m "%s on %s" %s %s'
        % (
            drucker.vars.DB_CONTAINER,
            str(date.today()),
            drucker.vars.DB_CONTAINER,
            drucker.vars.DB_IMAGE,
        ),
        shell=True,
    )

    print(colorful.white_on_blue("Deleting initial container..."))
    subprocess.getoutput(
        "docker rm -f %s > /dev/null 2>&1" % (drucker.vars.DB_CONTAINER)
    )
    create_db_container(drucker)
Esempio n. 28
0
def run_antechamber(molecule_name, input_filename, charge_method="bcc", net_charge=None, gaff_mol2_filename=None, frcmod_filename=None):
    """Run AmberTools antechamber and parmchk2 to create GAFF mol2 and frcmod files.

    Parameters
    ----------
    molecule_name : str
        Name of the molecule to be parameterized, will be used in output filenames.
    ligand_filename : str
        The molecule to be parameterized.  Must be tripos mol2 format.
    charge_method : str, optional
        If not None, the charge method string will be passed to Antechamber.
    net_charge : int, optional
        If not None, net charge of the molecule to be parameterized.
        If None, Antechamber sums up partial charges from the input file.
    gaff_mol2_filename : str, optional, default=None
        Name of GAFF mol2 filename to output.  If None, uses local directory
        and molecule_name
    frcmod_filename : str, optional, default=None
        Name of GAFF frcmod filename to output.  If None, uses local directory
        and molecule_name

    Returns
    -------
    gaff_mol2_filename : str
        GAFF format mol2 filename produced by antechamber
    frcmod_filename : str
        Amber frcmod file produced by prmchk
    """

    ext = parse_ligand_filename(input_filename)[1]

    filetype = ext[1:]
    if filetype != "mol2":
        raise(ValueError("Must input mol2 filename"))


    if gaff_mol2_filename is None:
        gaff_mol2_filename = molecule_name + '.gaff.mol2'
    if frcmod_filename is None:
        frcmod_filename = molecule_name + '.frcmod'

    cmd = "antechamber -i %s -fi mol2 -o %s -fo mol2 -s 2" % (input_filename, gaff_mol2_filename)
    if charge_method is not None:
        cmd += ' -c %s' % charge_method

    if net_charge is not None:
        cmd += ' -nc %d' % net_charge

    logger.debug(cmd)

    output = getoutput(cmd)
    logger.debug(output)

    cmd = "parmchk2 -i %s -f mol2 -o %s" % (gaff_mol2_filename, frcmod_filename)
    logger.debug(cmd)

    output = getoutput(cmd)
    logger.debug(output)

    return gaff_mol2_filename, frcmod_filename
Esempio n. 29
0
 def _update_repos(self):
     '''
     Prepare the reposiroties, return dict with repo information:
     {'<repo dir>': {'last_rev': '<last revision number>',
                      'files': '<list of files changed since last revision>'}
     '''
     repo_info = {}
     for base in self.roots:
         repo_info[base] = {}
         if not os.path.isdir(base):
             # checkout the repo
             co_cmd = 'svn co ' + self.roots[base] + ' ' + base
             lines = bytes.decode(subprocess.getoutput(co_cmd)).splitlines()
             repo_info[base]['last_rev'] = None
             repo_info[base]['files'] = self._find_pkgbuilds(base, lines)
         else:
             # Check the release numbers and run an update
             l_cmd = 'svn info ' + base + " | grep Revision: | awk '{print $2}'"
             l_rev = int(subprocess.getoutput(i_cmd).strip())
             repo_info['last_rev'] = str(l_rev)
             r_cmd = 'svn info ' + self.roots[base] + " | grep Revision: | awk '{print $2}'"
             r_rev = int(subprocess.getoutput(r_cmd).strip())
             if r_rev > l_rev:
                 # The local repo is out of date, update!
                 u_cmd = 'svn up ' + base
                 lines = bytes.decode(subprocess.getoutput(u_cmd)).splitlines()
                 repo_info[base]['files'] = self._find_pkgbuilds(base, lines)
     return repo_info
Esempio n. 30
0
def find_gateway(interface):
    """
    Validate gateway on the system

    Ensures that the provided interface object is in fact configured as default
    route on the system.

    Returns gateway IP (reachable from interface) if default route is found,
    otherwise returns None.
    """

    address_family = interface.version
    output = subprocess.getoutput("ip -{} route".format(address_family))

    pattern = re.compile("default\s+via\s+(\S+)\s+")
    match = re.search(pattern, output)

    if match:
        gateway_ip = match.group(1)
        reverse_route_output = subprocess.getoutput("ip route get {}"
                                                    .format(gateway_ip))
        pattern = re.compile("{}.+src\s+{}".format(gateway_ip, interface.ip))
        if not re.search(pattern, reverse_route_output):
            logging.warning("Default route doesn't match iterface specified: {}"
                            .format(reverse_route_output))
            return None
        else:
            return gateway_ip
    else:
        logging.warning("Can't find gateway address on system")
        return None
Esempio n. 31
0
def run_command(cmd_line):

    a = subprocess.getoutput(cmd_line)
    print(a)
Esempio n. 32
0
def muta_config():
    c_poolsize = get_int("poolsize", 200000)
    c_timeout_gap = get_int("timeout_gap", 999999)
    c_cycles_limit = get_int("cycles_limit", 630000000)
    c_tx_num_limit = get_int("tx_num_limit", 30000)

    with open("./res/muta_config_request.toml") as f:
        face_config_list = toml.load(f)["node"]

    with util.chdir(conf.config["muta"]["path"]):
        r = subprocess.getoutput(
            f"./build/muta-keypair -n {len(face_config_list)}")
        with open("./build/keypairs.json", "w") as f:
            f.write(r)
        keypairs = json.loads(r)

        assert "common_ref" in keypairs
        for e in keypairs["keypairs"]:
            assert "private_key" in e
            assert "public_key" in e
            assert "address" in e
            assert "bls_public_key" in e

        genesis = toml.load(conf.config["muta"]["genesis_template"])
        assert genesis["services"][1]["name"] == "metadata"
        payload = json.loads(genesis["services"][1]["payload"])
        payload["common_ref"] = keypairs["common_ref"]
        payload["timeout_gap"] = c_timeout_gap
        payload["cycles_limit"] = c_cycles_limit
        payload["tx_num_limit"] = c_tx_num_limit
        payload["verifier_list"] = []

        for i, e in enumerate(keypairs["keypairs"]):
            if i >= (len(face_config_list) -
                     conf.config["muta"]["sync_node_number"]):
                break
            a = {
                "bls_pub_key": e["bls_public_key"],
                "address": e["address"],
                "propose_weight": 1,
                "vote_weight": 1,
            }
            payload["verifier_list"].append(a)
        genesis["services"][1]["payload"] = json.dumps(payload)
        with open("./build/genesis.toml", "w") as f:
            toml.dump(genesis, f)

        node_config_raw = toml.load(conf.config["muta"]["config_template"])
        for i in range(len(face_config_list)):
            node_config = copy.deepcopy(node_config_raw)
            host_config = face_config_list[i]
            keypair = keypairs["keypairs"][i]
            node_config["privkey"] = keypair["private_key"]
            node_config["data_path"] = host_config["data"]
            node_config["graphql"]["listening_address"] = "0.0.0.0:" + str(
                host_config["api_port"])
            node_config["network"]["listening_address"] = "0.0.0.0:" + str(
                host_config["p2p_port"])
            node_config["logger"]["log_path"] = os.path.join(
                host_config["data"], "logs")
            node_config["mempool"]["pool_size"] = c_poolsize
            node_config["network"]["bootstraps"] = [{
                "pubkey":
                keypairs["keypairs"][0]["public_key"],
                "address":
                face_config_list[0]["host"] + ":" +
                str(face_config_list[0]["p2p_port"]),
            }]

            with open(f"./build/config_{i+1}.toml", "w") as f:
                toml.dump(node_config, f)
Esempio n. 33
0
def git_describe():
    stdout = subprocess.getoutput('git describe --tags')
    return stdout.strip()
Esempio n. 34
0
def using_clang():
    """Will we be using a clang compiler?"""
    compiler = new_compiler()
    customize_compiler(compiler)
    compiler_ver = getoutput("{0} -v".format(compiler.compiler[0]))
    return 'clang' in compiler_ver
Esempio n. 35
0
def test_usage():
    """usage"""

    for flag in ['', '-h', '--help']:
        out = getoutput('{} {}'.format(prg, flag))
        assert out.lower().startswith('usage')
Esempio n. 36
0
 def test_bad_path(self):
     output = subprocess.getoutput(
         './mini_ls.py test_paths_')
     self.assertIn('Please provide a valid path', output)
Esempio n. 37
0
 def test_one_path_not_recursive(self):
     output = subprocess.getoutput('./mini_ls.py test_paths_1')
     self.assertIn('test_paths_1', output)
     self.assertIn('test1_2.txt', output)
     self.assertIn('test1_1.txt', output)
Esempio n. 38
0
 def test_current_dir_recursive(self):
     output = subprocess.getoutput('./mini_ls.py -r')
     self.assertIn('test_paths_2_1', output)
     self.assertIn('test2_2.txt', output)
     self.assertIn('test2_1_1.txt', output)
Esempio n. 39
0
#!/usr/bin/python3.6

import subprocess
import socket
s = socket.socket()
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
port = 2222
ip = "192.168.2.13"
s.bind((ip, port))
s.listen()

c, y = s.accept()
while True:
    ch = c.recv(20)
    if ch.decode() == "exit":
        break
    cmd = subprocess.getoutput(ch.decode())
    x = cmd.encode()
    c.send(x)

c.close()
s.close()
Esempio n. 40
0
print("服务端启动,接收信息中")
while True:
    conn, addr = server.accept()
    print("新客户端接入")
    while True:
        data = conn.recv(1024)
        if data.decode() == "exit":
            print("客户端退出,等待新客户端接入")
            break
        else:
            if "get" in data.decode():
                data_in = data.decode().split()
                if os.path.isfile(data_in[1].strip()):
                    print((data_in[1].strip()))
                    f = open((data_in[1]), "rb")
                    m = hashlib.md5()
                    file_size = os.stat(data_in[1]).st_size
                    conn.send(str(file_size).encode())
                    conn.recv(1024)
                    for line in f:
                        m.update(line)
                        conn.send(line)
                    conn.send(m.hexdigest().encode())
                    f.close()
            else:
                info = subprocess.getoutput(data.decode())
                conn.send(str(len(info.encode())).encode("utf-8"))
                client_ack = conn.recv(1024)
                conn.send(info.encode("utf-8"))
server.close()
Esempio n. 41
0
def test_one():
    """one item"""

    out = getoutput('{} chips'.format(prg))
    assert out.strip() == 'You are bringing chips.'
Esempio n. 42
0
def test_two():
    """two items"""

    out = getoutput('{} Coke "french fries"'.format(prg))
    assert out.strip() == 'You are bringing Coke and french fries.'
Esempio n. 43
0
def register2MNI(fslDir, inFile, outFile, affmat, warp):
    """ This function registers an image (or time-series of images) to MNI152 T1 2mm. If no affmat is defined, it only warps (i.e. it assumes that the data has been registerd to the structural scan associated with the warp-file already). If no warp is defined either, it only resamples the data to 2mm isotropic if needed (i.e. it assumes that the data has been registered to a MNI152 template). In case only an affmat file is defined, it assumes that the data has to be linearly registered to MNI152 (i.e. the user has a reason not to use non-linear registration on the data).

    Parameters
    ---------------------------------------------------------------------------------
    fslDir:     Full path of the bin-directory of FSL
    inFile:     Full path to the data file (nii.gz) which has to be registerd to MNI152 T1 2mm
    outFile:    Full path of the output file
    affmat:     Full path of the mat file describing the linear registration (if data is still in native space)
    warp:       Full path of the warp file describing the non-linear registration (if data has not been registered to MNI152 space yet)

    Output (within the requested output directory)
    ---------------------------------------------------------------------------------
    melodic_IC_mm_MNI2mm.nii.gz merged file containing the mixture modeling thresholded Z-statistical maps registered to MNI152 2mm """

    # Import needed modules
    import os
    import subprocess

    # Define the MNI152 T1 2mm template
    fslnobin = fslDir.rsplit('/', 2)[0]
    ref = os.path.join(fslnobin, 'data', 'standard',
                       'MNI152_T1_2mm_brain.nii.gz')

    # If the no affmat- or warp-file has been specified, assume that the data is already in MNI152 space. In that case only check if resampling to 2mm is needed
    if (len(affmat) == 0) and (len(warp) == 0):
        # Get 3D voxel size
        pixdim1 = float(
            subprocess.getoutput(
                '%sfslinfo %s | grep pixdim1 | awk \'{print $2}\'' %
                (fslDir, inFile)))
        pixdim2 = float(
            subprocess.getoutput(
                '%sfslinfo %s | grep pixdim2 | awk \'{print $2}\'' %
                (fslDir, inFile)))
        pixdim3 = float(
            subprocess.getoutput(
                '%sfslinfo %s | grep pixdim3 | awk \'{print $2}\'' %
                (fslDir, inFile)))

        # If voxel size is not 2mm isotropic, resample the data, otherwise copy the file
        if (pixdim1 != 2) or (pixdim2 != 2) or (pixdim3 != 2):
            os.system(' '.join([
                os.path.join(fslDir,
                             'flirt'), ' -ref ' + ref, ' -in ' + inFile,
                ' -out ' + outFile, ' -applyisoxfm 2 -interp trilinear'
            ]))
        else:
            os.system('cp ' + inFile + ' ' + outFile)

    # If only a warp-file has been specified, assume that the data has already been registered to the structural scan. In that case apply the warping without a affmat
    elif (len(affmat) == 0) and (len(warp) != 0):
        # Apply warp
        os.system(' '.join([
            os.path.join(fslDir,
                         'applywarp'), '--ref=' + ref, '--in=' + inFile,
            '--out=' + outFile, '--warp=' + warp, '--interp=trilinear'
        ]))

    # If only a affmat-file has been specified perform affine registration to MNI
    elif (len(affmat) != 0) and (len(warp) == 0):
        os.system(' '.join([
            os.path.join(fslDir, 'flirt'), '-ref ' + ref, '-in ' + inFile,
            '-out ' + outFile, '-applyxfm -init ' + affmat, '-interp trilinear'
        ]))

    # If both a affmat- and warp-file have been defined, apply the warping accordingly
    else:
        os.system(' '.join([
            os.path.join(fslDir, 'applywarp'), '--ref=' + ref,
            '--in=' + inFile, '--out=' + outFile, '--warp=' + warp,
            '--premat=' + affmat, '--interp=trilinear'
        ]))
Esempio n. 44
0
def feature_spatial(fslDir, tempDir, aromaDir, melIC):
    """ This function extracts the spatial feature scores. For each IC it determines the fraction of the mixture modeled thresholded Z-maps respecitvely located within the CSF or at the brain edges, using predefined standardized masks.

    Parameters
    ---------------------------------------------------------------------------------
    fslDir:     Full path of the bin-directory of FSL
    tempDir:    Full path of a directory where temporary files can be stored (called 'temp_IC.nii.gz')
    aromaDir:   Full path of the ICA-AROMA directory, containing the mask-files (mask_edge.nii.gz, mask_csf.nii.gz & mask_out.nii.gz)
    melIC:      Full path of the nii.gz file containing mixture-modeled threholded (p>0.5) Z-maps, registered to the MNI152 2mm template

    Returns
    ---------------------------------------------------------------------------------
    edgeFract:  Array of the edge fraction feature scores for the components of the melIC file
    csfFract:   Array of the CSF fraction feature scores for the components of the melIC file"""

    # Import required modules
    import numpy as np
    import os
    import subprocess

    # Get the number of ICs
    numICs = int(
        subprocess.getoutput(
            '%sfslinfo %s | grep dim4 | head -n1 | awk \'{print $2}\'' %
            (fslDir, melIC)))

    # Loop over ICs
    edgeFract = np.zeros(numICs)
    csfFract = np.zeros(numICs)
    for i in range(0, numICs):
        # Define temporary IC-file
        tempIC = os.path.join(tempDir, 'temp_IC.nii.gz')

        # Extract IC from the merged melodic_IC_thr2MNI2mm file
        os.system(' '.join(
            [os.path.join(fslDir, 'fslroi'), melIC, tempIC,
             str(i), '1']))

        # Change to absolute Z-values
        os.system(' '.join(
            [os.path.join(fslDir, 'fslmaths'), tempIC, '-abs', tempIC]))

        # Get sum of Z-values within the total Z-map (calculate via the mean and number of non-zero voxels)
        totVox = int(
            subprocess.getoutput(' '.join([
                os.path.join(fslDir, 'fslstats'), tempIC,
                '-V | awk \'{print $1}\''
            ])))

        if not (totVox == 0):
            totMean = float(
                subprocess.getoutput(' '.join(
                    [os.path.join(fslDir, 'fslstats'), tempIC, '-M'])))
        else:
            print('     - The spatial map of component ' + str(i + 1) +
                  ' is empty. Please check!')
            totMean = 0

        totSum = totMean * totVox

        # Get sum of Z-values of the voxels located within the CSF (calculate via the mean and number of non-zero voxels)
        csfVox = int(
            subprocess.getoutput(' '.join([
                os.path.join(fslDir, 'fslstats'), tempIC, '-k mask_csf.nii.gz',
                '-V | awk \'{print $1}\''
            ])))

        if not (csfVox == 0):
            csfMean = float(
                subprocess.getoutput(' '.join([
                    os.path.join(fslDir, 'fslstats'), tempIC,
                    '-k mask_csf.nii.gz', '-M'
                ])))
        else:
            csfMean = 0

        csfSum = csfMean * csfVox

        # Get sum of Z-values of the voxels located within the Edge (calculate via the mean and number of non-zero voxels)
        edgeVox = int(
            subprocess.getoutput(' '.join([
                os.path.join(fslDir, 'fslstats'), tempIC,
                '-k mask_edge.nii.gz', '-V | awk \'{print $1}\''
            ])))
        if not (edgeVox == 0):
            edgeMean = float(
                subprocess.getoutput(' '.join([
                    os.path.join(fslDir, 'fslstats'), tempIC,
                    '-k mask_edge.nii.gz', '-M'
                ])))
        else:
            edgeMean = 0

        edgeSum = edgeMean * edgeVox

        # Get sum of Z-values of the voxels located outside the brain (calculate via the mean and number of non-zero voxels)
        outVox = int(
            subprocess.getoutput(' '.join([
                os.path.join(fslDir, 'fslstats'), tempIC, '-k mask_out.nii.gz',
                '-V | awk \'{print $1}\''
            ])))
        if not (outVox == 0):
            outMean = float(
                subprocess.getoutput(' '.join([
                    os.path.join(fslDir, 'fslstats'), tempIC,
                    '-k mask_out.nii.gz', '-M'
                ])))
        else:
            outMean = 0

        outSum = outMean * outVox

        # Determine edge and CSF fraction
        if not (totSum == 0):
            edgeFract[i] = old_div((outSum + edgeSum), (totSum - csfSum))
            csfFract[i] = old_div(csfSum, totSum)
        else:
            edgeFract[i] = 0
            csfFract[i] = 0

    # Remove the temporary IC-file
    os.remove(tempIC)

    # Return feature scores
    return edgeFract, csfFract
Esempio n. 45
0
def run_ICA_AROMA(outDir,
                  inFile,
                  mc,
                  TR,
                  mask="",
                  mask_csf="",
                  denType="nonaggr",
                  melDir="",
                  dim=0,
                  overwrite=False):
    ###additional function for the execution of ICA_AROMA within RABIES
    import os
    import subprocess
    import shutil
    import rabies.conf_reg_pkg.mod_ICA_AROMA.classification_plots as classification_plots
    import rabies.conf_reg_pkg.mod_ICA_AROMA.ICA_AROMA_functions as aromafunc

    # Change to script directory
    cwd = os.path.realpath(os.path.curdir)
    scriptDir = os.path.dirname(os.path.abspath(__file__))
    os.chdir(scriptDir)

    print(
        '\n------------------------------- RUNNING ICA-AROMA ------------------------------- '
    )
    print(
        '--------------- \'ICA-based Automatic Removal Of Motion Artifacts\' --------------- \n'
    )

    # Define variables based on the type of input (i.e. Feat directory or specific input arguments), and check whether the specified files exist.
    cancel = False

    # Check whether the files exist
    if not inFile:
        print('No input file specified.')
    else:
        if not os.path.isfile(inFile):
            print('The specified input file does not exist.')
            cancel = True
    if not mc:
        print('No mc file specified.')
    else:
        if not os.path.isfile(mc):
            print('The specified mc file does does not exist.')
            cancel = True

    # Check if the mask exists, when specified.
    if mask:
        if not os.path.isfile(mask):
            print('The specified mask does not exist.')
            cancel = True

    # Check if the type of denoising is correctly specified, when specified
    if not (denType == 'nonaggr') and not (denType == 'aggr') and not (
            denType == 'both') and not (denType == 'no'):
        print(
            'Type of denoising was not correctly specified. Non-aggressive denoising will be run.'
        )
        denType = 'nonaggr'

    # If the criteria for file/directory specifications have not been met. Cancel ICA-AROMA.
    if cancel:
        print(
            '\n----------------------------- ICA-AROMA IS CANCELED -----------------------------\n'
        )
        exit()

    #------------------------------------------- PREPARE -------------------------------------------#

    # Define the FSL-bin directory
    fslDir = os.path.join(os.environ["FSLDIR"], 'bin', '')

    # Create output directory if needed
    if os.path.isdir(outDir) and overwrite is False:
        print(
            'Output directory', outDir, """already exists.
              AROMA will not continue.
              Rerun with the -overwrite option to explicitly overwrite existing output."""
        )
        exit()
    elif os.path.isdir(outDir) and overwrite is True:
        print('Warning! Output directory', outDir,
              'exists and will be overwritten.\n')
        shutil.rmtree(outDir)
        os.makedirs(outDir)
    else:
        os.makedirs(outDir)

    # Get TR of the fMRI data, if not specified
    if TR:
        TR = TR
    else:
        cmd = ' '.join([
            os.path.join(fslDir, 'fslinfo'), inFile,
            '| grep pixdim4 | awk \'{print $2}\''
        ])
        TR = float(subprocess.getoutput(cmd))

    # Check TR
    if TR == 0:
        print(
            'TR is zero. ICA-AROMA requires a valid TR and will therefore exit. Please check the header, or define the TR as an additional argument.\n----------------------------- ICA-AROMA IS CANCELED -----------------------------\n'
        )
        exit()

    # Define mask.
    mask_cp = os.path.join(outDir, 'mask.nii.gz')
    shutil.copyfile(mask, mask_cp)
    mask = mask_cp

    #---------------------------------------- Run ICA-AROMA ----------------------------------------#

    print('Step 1) MELODIC')
    aromafunc.runICA(fslDir, inFile, outDir, melDir, mask, dim, TR)
    melIC = os.path.join(outDir, 'melodic_IC_thr.nii.gz')

    print('Step 2) Automatic classification of the components')

    print('  - *modified version skips commonspace registration')

    print('  - computing edge and out masks')
    mask_edge = os.path.join(outDir, 'mask_edge.nii.gz')
    mask_out = os.path.join(outDir, 'mask_out.nii.gz')
    aromafunc.compute_edge_mask(mask, mask_edge, num_edge_voxels=1)
    aromafunc.compute_out_mask(mask, mask_out)

    print('  - extracting the CSF & Edge fraction features')
    #modified inputs for the spatial features, by providing the required masks manually
    edgeFract, csfFract = aromafunc.mod_feature_spatial(
        fslDir, outDir, melIC, mask_csf, mask_edge, mask_out)

    print('  - extracting the Maximum RP correlation feature')
    melmix = os.path.join(outDir, 'melodic.ica', 'melodic_mix')
    maxRPcorr = aromafunc.feature_time_series(melmix, mc)

    print('  - extracting the High-frequency content feature')
    melFTmix = os.path.join(outDir, 'melodic.ica', 'melodic_FTmix')
    HFC = aromafunc.feature_frequency(melFTmix, TR)

    print('  - classification')
    motionICs = aromafunc.classification(outDir, maxRPcorr, edgeFract, HFC,
                                         csfFract)
    classification_plots.classification_plot(
        os.path.join(outDir, 'classification_overview.txt'), outDir)

    if (denType != 'no'):
        print('Step 3) Data denoising')
        aromafunc.denoising(fslDir, inFile, outDir, melmix, denType, motionICs)

    # Revert to old directory
    os.chdir(cwd)

    print(
        '\n----------------------------------- Finished -----------------------------------\n'
    )
Esempio n. 46
0
def runICA(fslDir, inFile, outDir, melDirIn, mask, dim, TR):
    """ This function runs MELODIC and merges the mixture modeled thresholded ICs into a single 4D nifti file

    Parameters
    ---------------------------------------------------------------------------------
    fslDir:     Full path of the bin-directory of FSL
    inFile:     Full path to the fMRI data file (nii.gz) on which MELODIC should be run
    outDir:     Full path of the output directory
    melDirIn:   Full path of the MELODIC directory in case it has been run before, otherwise define empty string
    mask:       Full path of the mask to be applied during MELODIC
    dim:        Dimensionality of ICA
    TR:     TR (in seconds) of the fMRI data

    Output (within the requested output directory)
    ---------------------------------------------------------------------------------
    melodic.ica     MELODIC directory
    melodic_IC_thr.nii.gz   merged file containing the mixture modeling thresholded Z-statistical maps located in melodic.ica/stats/ """

    # Import needed modules
    import os
    import subprocess

    # Define the 'new' MELODIC directory and predefine some associated files
    melDir = os.path.join(outDir, 'melodic.ica')
    melIC = os.path.join(melDir, 'melodic_IC.nii.gz')
    melICmix = os.path.join(melDir, 'melodic_mix')
    melICthr = os.path.join(outDir, 'melodic_IC_thr.nii.gz')

    # When a MELODIC directory is specified,
    # check whether all needed files are present.
    # Otherwise... run MELODIC again
    if len(melDir) != 0 and os.path.isfile(
            os.path.join(melDirIn, 'melodic_IC.nii.gz')) and os.path.isfile(
                os.path.join(melDirIn, 'melodic_FTmix')) and os.path.isfile(
                    os.path.join(melDirIn, 'melodic_mix')):

        print('  - The existing/specified MELODIC directory will be used.')

        # If a 'stats' directory is present (contains thresholded spatial maps)
        # create a symbolic link to the MELODIC directory.
        # Otherwise create specific links and
        # run mixture modeling to obtain thresholded maps.
        if os.path.isdir(os.path.join(melDirIn, 'stats')):
            os.symlink(melDirIn, melDir)
        else:
            print(
                '  - The MELODIC directory does not contain the required \'stats\' folder. Mixture modeling on the Z-statistical maps will be run.'
            )

            # Create symbolic links to the items in the specified melodic directory
            os.makedirs(melDir)
            for item in os.listdir(melDirIn):
                os.symlink(os.path.join(melDirIn, item),
                           os.path.join(melDir, item))

            # Run mixture modeling
            os.system(' '.join([
                os.path.join(fslDir, 'melodic'), '--in=' + melIC,
                '--ICs=' + melIC, '--mix=' + melICmix, '--outdir=' + melDir,
                '--Ostats --mmthresh=0.5'
            ]))

    else:
        # If a melodic directory was specified, display that it did not contain all files needed for ICA-AROMA (or that the directory does not exist at all)
        if len(melDirIn) != 0:
            if not os.path.isdir(melDirIn):
                print(
                    '  - The specified MELODIC directory does not exist. MELODIC will be run seperately.'
                )
            else:
                print(
                    '  - The specified MELODIC directory does not contain the required files to run ICA-AROMA. MELODIC will be run seperately.'
                )

        # Run MELODIC
        os.system(' '.join([
            os.path.join(fslDir, 'melodic'), '--in=' + inFile,
            '--outdir=' + melDir, '--mask=' + mask, '--dim=' + str(dim),
            '--Ostats --nobet --mmthresh=0.5 --report', '--tr=' + str(TR)
        ]))

    # Get number of components
    cmd = ' '.join([
        os.path.join(fslDir, 'fslinfo'), melIC,
        '| grep dim4 | head -n1 | awk \'{print $2}\''
    ])
    nrICs = int(float(subprocess.getoutput(cmd)))

    # Merge mixture modeled thresholded spatial maps. Note! In case that mixture modeling did not converge, the file will contain two spatial maps. The latter being the results from a simple null hypothesis test. In that case, this map will have to be used (first one will be empty).
    for i in range(1, nrICs + 1):
        # Define thresholded zstat-map file
        zTemp = os.path.join(melDir, 'stats',
                             'thresh_zstat' + str(i) + '.nii.gz')
        cmd = ' '.join([
            os.path.join(fslDir, 'fslinfo'), zTemp,
            '| grep dim4 | head -n1 | awk \'{print $2}\''
        ])
        lenIC = int(float(subprocess.getoutput(cmd)))

        # Define zeropad for this IC-number and new zstat file
        cmd = ' '.join([os.path.join(fslDir, 'zeropad'), str(i), '4'])
        ICnum = subprocess.getoutput(cmd)
        zstat = os.path.join(outDir, 'thr_zstat' + ICnum)

        # Extract last spatial map within the thresh_zstat file
        os.system(' '.join([
            os.path.join(fslDir, 'fslroi'),
            zTemp,  # input
            zstat,  # output
            str(lenIC - 1),  # first frame
            '1'
        ]))  # number of frames

    # Merge and subsequently remove all mixture modeled Z-maps within the output directory
    os.system(' '.join([
        os.path.join(fslDir, 'fslmerge'),
        '-t',  # concatenate in time
        melICthr,  # output
        os.path.join(outDir, 'thr_zstat????.nii.gz')
    ]))  # inputs

    os.system('rm ' + os.path.join(outDir, 'thr_zstat????.nii.gz'))

    # Apply the mask to the merged file (in case a melodic-directory was predefined and run with a different mask)
    os.system(' '.join(
        [os.path.join(fslDir, 'fslmaths'), melICthr, '-mas ' + mask,
         melICthr]))
Esempio n. 47
0
subprocess.call("termux-wake-lock")

# This part enable sys.stdout.read(1)
# to read one character without stopping.
fd = sys.stdin.fileno()
fl = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
old = tty.tcgetattr(fd)
tty.setcbreak(fd)

# \033[?25l makes curser invisible.
# \033[?47 saves current window.
# \u001b[0m resets all colors.
sys.stdout.write("\033[?25l\033[?47h\u001b[0m")

option = json.loads(subprocess.getoutput(
    "termux-dialog radio -v 'Timer,Alarm,Clock,Interval'"))["text"]
if option == "Timer":
    timer()
if option == "Alarm":
    alarmClock()
if option == "Clock":
    clock()
if option == "Interval":
    intervalTimer()

# \033[?47l loads window saved in the beginning.
# \033[?25h makes curser visible.
sys.stdout.write("\033[?47l\033[?25h")

# Stop input mode
tty.tcsetattr(fd, tty.TCSAFLUSH, old)
Esempio n. 48
0
def intervalTimer():
    intervalOption = json.loads(subprocess.getoutput(
        "termux-dialog radio -v 'Interval repeat,Interval variable'"))["text"]

    intervals = int(json.loads(subprocess.getoutput(
        "termux-dialog counter -r '1,100,2' -t 'Intervals'"))["text"])

    if intervalOption == "Interval repeat":
        work = json.loads(subprocess.getoutput(
            "termux-dialog -t 'Work' -i 'Format like m:s'"))["text"]
        if len([i for i in work.split(":") if i.isdigit()]) != 2:
            return
        rest = json.loads(subprocess.getoutput(
            "termux-dialog -t 'Rest' -i 'Format like m:s'"))["text"]
        if len([i for i in rest.split(":") if i.isdigit()]) != 2:
            return
        work = timeToSeconds(work, True)
        rest = timeToSeconds(rest, True)

    if intervalOption == "Interval variable":
        work = []
        rest = []
        for i in range(intervals):
            work.append(json.loads(subprocess.getoutput(
                "termux-dialog -t 'Work' -i 'Format like m:s'"))["text"])
            if len([i for i in work[i].split(":") if i.isdigit()]) != 2:
                return
            work[i] = timeToSeconds(work[i], True)
            rest.append(json.loads(subprocess.getoutput(
                "termux-dialog -t 'Rest' -i 'Format like m:s'"))["text"])
            if len([i for i in rest[i].split(":") if i.isdigit()]) != 2:
                return
            rest[i] = timeToSeconds(rest[i], True)

    subprocess.Popen("termux-tts-speak 'prepare'", shell=True)
    currentAction = "prepare"
    beepsDone = [False, False, False]
    endTime = round(time.time()) + 10
    quit = False
    while True:
        timeLeft = endTime-round(time.time())

        if currentAction == "work":
            color = "red"
        elif currentAction == "rest" or currentAction == "prepare":
            color = "green"

        if timeLeft <= 3 and not beepsDone[timeLeft-1]:
            playbeepWithOutPause()
            beepsDone[timeLeft-1] = True

        sys.stdout.write(
            "\u001b[1000D" + displayText((datetime.strptime("0:0", "%M:%S") + timedelta(seconds=timeLeft)).strftime("%M:%S"), color))
        sys.stdout.flush()

        if timeLeft <= 0:
            for i in range(3):
                beepsDone[i] = False

            if currentAction == "prepare":
                if intervalOption == "Interval repeat":
                    endTime = round(time.time()) + work
                if intervalOption == "Interval variable":
                    endTime = round(time.time()) + work[0]
                currentAction = "work"
                subprocess.Popen("termux-tts-speak 'work'", shell=True)
            elif currentAction == "rest":
                intervals -= 1
                if intervals == 0:
                    break
                if intervalOption == "Interval repeat":
                    endTime = round(time.time()) + work
                if intervalOption == "Interval variable":
                    endTime = round(time.time()) + work[-intervals]
                currentAction = "work"
                subprocess.Popen("termux-tts-speak 'work'", shell=True)
            elif currentAction == "work":
                if intervalOption == "Interval repeat":
                    endTime = round(time.time()) + rest
                if intervalOption == "Interval variable":
                    endTime = round(time.time()) + rest[-intervals]
                currentAction = "rest"
                subprocess.Popen("termux-tts-speak 'rest'", shell=True)

        keyInput = sys.stdin.read(1)
        if keyInput == "q":
            quit = True
            break
        if keyInput == "p":
            while 1:
                keyInput = sys.stdin.read(1)
                if keyInput == "p":
                    break
                if keyInput == "q":
                    quit = True
                    break
            if quit:
                break
            endTime = round(time.time()) + timeLeft
    if not quit:
        subprocess.call("termux-tts-speak 'done'", shell=True)
Esempio n. 49
0
parser.add_option("-m", "--metadata", help="Federation metadata file", action="store", type="string", dest="metadata")

(options, args) = parser.parse_args()
if len(args) == 0:
    print ("Missing filename(s). Specify '-' as filename to read from STDIN.\n")
    parser.print_help()
    sys.exit(-1)

if not options.metadata:
    parses.error("Option -m must be specified.")

#print (options.metadata)
#print (' '.join(args))

curpath = os.path.dirname(os.path.abspath(__file__))
output = subprocess.getoutput (f"python3 {curpath}/loganalysis.py -n {' '.join(args)}")
output = output.split("\n")

logins = {}
stampa = False
for row in output:
    if stampa:
       elems = row.split('|')
       logins[elems[1].strip()] = int(elems[0].strip())
       stampa = False
    if '-------' in row: stampa = True

#print (logins)

parser = parse(options.metadata)
Esempio n. 50
0
def getPakacgeVersionName(packageName):
    output = subprocess.getoutput("adb shell dumpsys package " + packageName +
                                  "|findstr versionName")
    print("2.当前应用的版本号是:" + output.strip())
Esempio n. 51
0
def test_if_topic_is_available():
    """Check that the topic extension can be enabled"""
    output = subprocess.getoutput("hg version -v --config extensions.topic=")
    assert "failed to import extension topic" not in output
Esempio n. 52
0
#!/usr/bin/python
# script makes a change log txt file from git logs
# usage: makeChangelog.py > CHANGELOG.txt

import subprocess

atags = subprocess.getoutput('git tag -n')
atags = atags.split('\n')
tags = subprocess.getoutput('git tag -l')
tags = tags.split('\n')

#for t in range(0, len(tags)-1):
for t in range(len(tags) - 1, -1, -1):
    if t == 0:
        #print "*** " + atags[t+1]
        print("*** " + atags[t])
    else:
        #print '\n\n*** ' + atags[t+1]
        print('\n\n*** ' + atags[t])
    #commandStr = 'git log %s..%s --pretty=%s' % (tags[t], tags[t+1], '%s')
    commandStr = 'git log %s..%s --pretty=%s' % (tags[t - 1], tags[t], '%s')
    changes = subprocess.getoutput(commandStr)
    changes = changes.split('\n')
    #changes = changes[::-1]
    for line in changes:
        print('  + ' + line)
Esempio n. 53
0
#!/usr/bin/python3

import cgi
import subprocess

print("content-type: text/html")
print()

mydata = cgi.FieldStorage()
volume = mydata.getvalue("rm_vol")

output = subprocess.getoutput("sudo docker volume rm " + volume)
print(output)
Esempio n. 54
0
import cgi

print("content-type:text/html")
print("\n")

form=cgi.FieldStorage()
node=form.getvalue('node')
sip=form.getvalue('sip')
cip=form.getvalue('cip')
spw=form.getvalue('spw')
cpw=form.getvalue('cpw')

#NFS Server

if node=="Server":
	sp.getoutput("sshpass -p {} ssh -o StrictHostKeyChecking=no -l root {} mkdir /nfsdata".format(spw,sip))
	sp.getoutput("sshpass -p {} scp -o StrictHostKeyChecking=no /var/www/cgi-bin/exports.py root@{}:/root/ ".format(spw,sip))
	sp.getoutput("sshpass -p {} ssh -o StrictHostKeyChecking=no -l root {} python /root/exports.py".format(spw,sip))
	sp.getoutput("sshpass -p {} ssh -o StrictHostKeyChecking=no -l root {} systemctl restart nfs".format(spw,sip))
	sp.getoutput("sshpass -p {} ssh -o StrictHostKeyChecking=no -l root {} systemctl enable nfs".format(spw,sip))
	x=sp.getstatusoutput("sshpass -p {} ssh -o StrictHostKeyChecking=no -l root {} exportfs -v".format(spw,sip))
	if x[0]==0:
		print("Server has been setup")
	else:
		print("Server setup failed")

#NFS Client

elif node=="Client":
	sp.getoutput("sshpass -p {} ssh -o StrictHostKeyChecking=no -l root {} mkdir /nfsdata".format(cpw,cip))
	x=sp.getstatusoutput("sshpass -p {} ssh -o StrictHostKeyChecking=no -l root {} mount {}:/nfsdata /nfsdata".format(cpw,cip,sip))
Esempio n. 55
0
# story,screenplay,dialogue
narrative = []

# music,lyrics
song = []

movies = [1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1173, 1174, 1176, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1210, 1211, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1274, 1275, 1277, 1278, 1283, 1284, 1286, 1287, 1288, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, 1352, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, 1366, 1367, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405, 1407, 1410, 1411, 1412, 1416, 1419, 1422, 1423, 1424, 1425, 1426, 1427, 1428, 1429, 1430, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439, 1440, 1441, 1442, 1443, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 1459, 1460, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1470, 1471, 1472, 1473, 1474, 1475, 1476, 1477, 1478, 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1487, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1517, 1518, 1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1528, 1533, 1534, 1535, 1536, 1539, 1541, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1564, 1565, 1566, 1567, 1568, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593, 1594, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1625, 1626, 1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637, 1638, 1639, 1640, 1641, 1643, 1644, 1645, 1646, 1647, 1648, 1649, 1650, 1651, 1652, 1658, 1661, 1662, 1663, 1665, 1666, 1668, 1669, 1670, 1671, 1672, 1673, 1674, 1675, 1676, 1677, 1678, 1679, 1680, 1681, 1682, 1683, 1684, 1685, 1686, 1687, 1688, 1689, 1690, 1691, 1692, 1693, 1694, 1695, 1696, 1697, 1698, 1699, 1700, 1701, 1702, 1703, 1704, 1705, 1706, 1707, 1708, 1709, 1710, 1711, 1712, 1713, 1714, 1715, 1716, 1717, 1718, 1719, 1720, 1721, 1722, 1723, 1724, 1725, 1726, 1727, 1728, 1730, 1731, 1732, 1733, 1734, 1735, 1737, 1739, 1740, 1741, 1742, 1743, 1744, 1745, 1746, 1748, 1749, 1750, 1751, 1752, 1753, 1754, 1755, 1756, 1757, 1758, 1759, 1761, 1762, 1763, 1765, 1766, 1767, 1768, 1769, 1770, 1771, 1772, 1773, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784, 1785, 1786, 1787, 1788, 1789, 1791, 1793, 1799, 1800, 1802, 1803, 1804, 1805, 1813, 1814, 1818, 1819, 1821, 1822, 1824, 1825, 1826, 1827, 1828, 1829, 1830, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1849, 1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1903, 1904, 1905, 1906, 1907, 1909, 1910, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1939, 1944, 1948, 1950, 1954, 1956, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2041, 2042, 2043, 2044, 2049, 2050, 2051, 2053, 2055, 2056, 2057, 2058, 2059, 2060, 2061, 2062, 2063, 2064, 2065, 2066, 2067, 2068, 2069, 2070, 2071, 2072, 2073, 2074, 2075, 2076, 2077, 2078, 2079, 2080, 2081, 2082, 2083, 2084, 2085, 2086, 2087, 2089, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, 2098, 2099, 2100, 2101, 2102, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 2110, 2111, 2112, 2113, 2114, 2115, 2116, 2117, 2118, 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2126, 2127, 2128, 2129, 2130, 2131, 2132, 2133, 2134, 2135, 2137, 2142, 2143, 2145, 2146, 2147, 2149, 2150, 2151, 2152, 2153, 2155, 2158, 2164, 2167, 2168, 2169, 2170, 2171, 2172, 2173, 2174, 2175, 2176, 2177, 2178, 2179, 2180, 2181, 2182, 2183, 2184, 2185, 2186, 2187, 2188, 2189, 2190, 2191, 2192, 2193, 2194, 2195, 2196, 2197, 2198, 2199, 2200, 2201, 2202, 2203, 2204, 2205, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2216, 2217, 2218, 2219, 2220, 2221, 2222, 2223, 2224, 2225, 2226, 2227, 2228, 2229, 2230, 2231, 2232, 2233, 2234, 2235, 2236, 2237, 2238, 2239, 2240, 2242, 2243, 2244, 2245, 2246, 2247, 2248, 2258, 2259, 2260, 2262, 2278, 2280, 2281, 2282, 2283, 2284, 2285, 2286, 2287, 2288, 2289, 2290, 2291, 2292, 2293, 2294, 2296, 2297, 2298, 2299, 2300, 2301, 2302, 2303, 2304, 2305, 2306, 2307, 2308, 2309, 2310, 2311, 2312, 2313, 2314, 2315, 2316, 2317, 2318, 2319, 2320, 2321, 2322, 2323, 2324, 2325, 2326, 2327, 2328, 2329, 2330, 2331, 2332, 2333, 2334, 2335, 2336, 2337, 2338, 2339, 2340, 2341, 2342, 2343, 2344, 2345, 2346, 2347, 2348, 2349, 2350, 2351, 2352, 2353, 2354, 2355, 2356, 2357, 2358, 2359, 2360, 2361, 2362, 2363, 2364, 2365, 2366, 2367, 2368, 2369, 2370, 2371, 2372, 2373, 2374, 2375, 2376, 2377, 2378, 2379, 2384, 2388, 2396, 2399, 2401, 2402, 2409, 2410, 2411, 2413, 2414, 2415, 2416, 2417, 2418, 2419, 2420, 2421, 2422, 2423, 2425, 2426, 2427, 2428, 2429, 2430, 2431, 2432, 2433, 2434, 2435, 2436, 2437, 2438, 2439, 2440, 2442, 2443, 2444, 2445, 2446, 2447, 2448, 2449, 2450, 2451, 2452, 2453, 2454, 2455, 2456, 2457, 2458, 2459, 2460, 2461, 2462, 2463, 2464, 2465, 2466, 2467, 2468, 2469, 2470, 2471, 2472, 2473, 2474, 2475, 2476, 2477, 2478, 2479, 2480, 2481, 2482, 2483, 2484, 2485, 2486, 2487, 2488, 2489, 2490, 2491, 2492, 2493, 2494, 2495, 2496, 2497, 2498, 2499, 2500, 2501, 2502, 2503, 2504, 2505, 2506, 2507, 2508, 2509, 2510, 2511, 2512, 2513, 2516, 2518, 2519, 2522, 2524, 2525, 2526, 2528, 2529, 2530, 2531, 2532, 2533, 2534, 2535, 2536, 2537, 2538, 2539, 2540, 2541, 2542, 2543, 2544, 2545, 2546, 2547, 2548, 2549, 2550, 2551, 2552, 2553, 2554, 2555, 2556, 2557, 2558, 2559, 2560, 2561, 2562, 2563, 2564, 2565, 2566, 2567, 2568, 2569, 2570, 2571, 2572, 2573, 2574, 2575, 2576, 2577, 2578, 2579, 2580, 2581, 2582, 2583, 2584, 2585, 2586, 2588, 2589, 2590, 2591, 2592, 2593, 2594, 2595, 2596, 2597, 2598, 2599, 2600, 2601, 2602, 2603, 2604, 2605, 2606, 2607, 2608, 2609, 2610, 2611, 2612, 2613, 2615, 2616, 2622, 2627, 2628, 2630, 2631, 2636, 2637, 2638, 2640, 2641, 2642, 2643, 2644, 2645, 2646, 2647, 2648, 2649, 2650, 2651, 2652, 2653, 2654, 2655, 2656, 2657, 2658, 2659, 2660, 2661, 2662, 2663, 2664, 2665, 2666, 2667, 2668, 2669, 2670, 2671, 2672, 2673, 2674, 2675, 2676, 2677, 2678, 2679, 2680, 2681, 2683, 2684, 2685, 2686, 2687, 2688, 2689, 2690, 2691, 2692, 2693, 2694, 2695, 2696, 2697, 2698, 2699, 2700, 2701, 2702, 2703, 2704, 2706, 2707, 2708, 2709, 2710, 2712, 2713, 2714, 2715, 2724, 2726, 2728, 2729, 2731, 2732, 2734, 2735, 2736, 2738, 2739, 2740, 2742, 2743, 2744, 2745, 2746, 2747, 2749, 2750, 2751, 2752, 2753, 2754, 2755, 2756, 2757, 2758, 2759, 2760, 2761, 2762, 2763, 2764, 2766, 2767, 2768, 2769, 2770, 2771, 2772, 2773, 2774, 2775, 2776, 2777, 2778, 2779, 2780, 2781, 2782, 2783, 2784, 2785, 2786, 2787, 2788, 2789, 2790, 2791, 2793, 2794, 2795, 2796, 2797, 2798, 2800, 2801, 2802, 2803, 2804, 2807, 2810, 2815, 2816, 2817, 2818, 2819, 2820, 2821, 2822, 2823, 2824, 2825, 2826, 2827, 2828, 2829, 2830, 2831, 2832, 2833, 2834, 2835, 2836, 2837, 2838, 2839, 2840, 2841, 2842, 2843, 2845, 2846, 2847, 2848, 2849, 2850, 2851, 2852, 2853, 2854, 2855, 2856, 2857, 2858, 2859, 2860, 2861, 2862, 2863, 2864, 2865, 2867, 2868, 2869, 2870, 2871, 2872, 2873, 2874, 2875, 2876, 2877, 2878, 2879, 2880, 2881, 2882, 2883, 2884, 2885, 2886, 2887, 2888, 2889, 2890, 2891, 2892, 2893, 2894, 2895, 2896, 2897, 2900, 2901, 2902, 2905, 2909, 2910, 2911, 2912, 2913, 2914, 2915, 2916, 2917, 2918, 2919, 2920, 2921, 2922, 2923, 2924, 2925, 2926, 2927, 2928, 2929, 2930, 2931, 2932, 2933, 2934, 2935, 2937, 2938, 2939, 2940, 2941, 2942, 2943, 2944, 2945, 2946, 2947, 2948, 2949, 2950, 2951, 2952, 2953, 2954, 2955, 2956, 2957, 2958, 2959, 2960, 2961, 2962, 2963, 2964, 2965, 2966, 2967, 2968, 2969, 2970, 2971, 2972, 2974, 2981, 2982, 2983, 2985, 2988, 2989, 2990, 2991, 2992, 2993, 2994, 2995, 2996, 2997, 2998, 2999, 3000, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3020, 3021, 3022, 3023, 3024, 3025, 3026, 3027, 3028, 3029, 3030, 3031, 3032, 3033, 3034, 3035, 3036, 3037, 3038, 3040, 3041, 3042, 3043, 3044, 3045, 3046, 3047, 3048, 3049, 3050, 3051, 3052, 3053, 3054, 3055, 3056, 3057, 3058, 3059, 3060, 3061, 3062, 3063, 3064, 3065, 3066, 3067, 3069, 3070, 3073, 3075, 3076, 3079, 3081, 3088, 3089, 3090, 3091, 3092, 3093, 3094, 3095, 3096, 3097, 3098, 3099, 3101, 3102, 3103, 3104, 3105, 3106, 3107, 3108, 3109, 3110, 3111, 3112, 3113, 3114, 3115, 3116, 3117, 3118, 3119, 3120, 3121, 3122, 3123, 3124, 3125, 3126, 3127, 3128, 3129, 3130, 3131, 3132, 3133, 3134, 3136, 3137, 3138, 3139, 3140, 3141, 3142, 3143, 3144, 3145, 3146, 3147, 3148, 3149, 3150, 3151, 3152, 3154, 3155, 3156, 3159, 3161, 3162, 3163, 3164, 3165, 3166, 3167, 3168, 3169, 3170, 3171, 3172, 3173, 3174, 3175, 3176, 3177, 3178, 3179, 3180, 3181, 3182, 3183, 3184, 3185, 3186, 3187, 3188, 3189, 3190, 3191, 3192, 3193, 3194, 3195, 3196, 3197, 3198, 3199, 3200, 3201, 3202, 3203, 3204, 3205, 3206, 3207, 3208, 3209, 3210, 3211, 3212, 3213, 3214, 3216, 3217, 3218, 3219, 3221, 3222, 3224, 3227, 3228, 3229, 3232, 3233, 3234, 3235, 3236, 3237, 3238, 3239, 3240, 3241, 3242, 3243, 3244, 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3252, 3253, 3254, 3255, 3256, 3257, 3258, 3259, 3260, 3261, 3262, 3263, 3264, 3265, 3266, 3267, 3268, 3269, 3270, 3271, 3272, 3273, 3274, 3275, 3276, 3277, 3278, 3279, 3280, 3281, 3282, 3283, 3284, 3285, 3286, 3287, 3288, 3289, 3290, 3291, 3293, 3294, 3295, 3296, 3297, 3298, 3299, 3300, 3301, 3302, 3303, 3304, 3305, 3306, 3308, 3309, 3310, 3311, 3312, 3313, 3314, 3315, 3317, 3318, 3320, 3321, 3322, 3323, 3324, 3325, 3326, 3327, 3328, 3329, 3330, 3331, 3332, 3333, 3334, 3335, 3336, 3338, 3339, 3340, 3341, 3342, 3343, 3344, 3345, 3346, 3348, 3349, 3350, 3352, 3353, 3354, 3355, 3356, 3357, 3358, 3359, 3360, 3361, 3362, 3363, 3364, 3365, 3366, 3367, 3368, 3369, 3370, 3371, 3372, 3373, 3374, 3375, 3376, 3377, 3378, 3379, 3380, 3381, 3382, 3383, 3384, 3385, 3386, 3387, 3388, 3389, 3390, 3391, 3392, 3393, 3394, 3395, 3396, 3397, 3398, 3399, 3400, 3401, 3402, 3403, 3404, 3405, 3406, 3407, 3408, 3410, 3411, 3412, 3413, 3414, 3415, 3416, 3417, 3418, 3419, 3420, 3421, 3422, 3423, 3424, 3425, 3426, 3427, 3428, 3429, 3432, 3433, 3434, 3435, 3437, 3442, 3443, 3444, 3445, 3446, 3447, 3449, 3450, 3451, 3452, 3453, 3454, 3455, 3456, 3457, 3459, 3460, 3461, 3462, 3463, 3464, 3465, 3466, 3467, 3468, 3469, 3470, 3471, 3472, 3473, 3474, 3475, 3476, 3477, 3478, 3479, 3480, 3481, 3482, 3483, 3484, 3485, 3486, 3487, 3488, 3489, 3490, 3491, 3492, 3493, 3494, 3495, 3496, 3497, 3498, 3499, 3500, 3501, 3502, 3503, 3504, 3505, 3506, 3507, 3508, 3509, 3510, 3511, 3512, 3513, 3514, 3515, 3516, 3517, 3518, 3520, 3521, 3522, 3523, 3524, 3525, 3526, 3527, 3528, 3529, 3530, 3531, 3532, 3533, 3534, 3535, 3536, 3537, 3538, 3539, 3540, 3541, 3543, 3544, 3546, 3547, 3548, 3549, 3550, 3551, 3552, 3553, 3554, 3555, 3556, 3557, 3558, 3559, 3560, 3561, 3562, 3563, 3564, 3565, 3566, 3567, 3568, 3569, 3570, 3571, 3572, 3573, 3575, 3576, 3577, 3578, 3579, 3580, 3581, 3582, 3583, 3584, 3585, 3586, 3587, 3588, 3589, 3590, 3591, 3593, 3594, 3595, 3596, 3597, 3598, 3599, 3600, 3601, 3602, 3603, 3604, 3605, 3606, 3607, 3608, 3609, 3610, 3611, 3612, 3613, 3614, 3615, 3616, 3617, 3618, 3619, 3622, 3623, 3624, 3625, 3626, 3627, 3628, 3629, 3630, 3631, 3632, 3633, 3634, 3635, 3636, 3637, 3638, 3639, 3640, 3641, 3642, 3643, 3644, 3645, 3646, 3647, 3648, 3649, 3650, 3651, 3652, 3653, 3654, 3655, 3656, 3657, 3658, 3659, 3660, 3661, 3662, 3663, 3664, 3665, 3666, 3667, 3668, 3669, 3670, 3671, 3672, 3673, 3674, 3675, 3676, 3677, 3678, 3679, 3680, 3681, 3682, 3683, 3684, 3685, 3686, 3687, 3688, 3689, 3690, 3691, 3692, 3693, 3694, 3697, 3698, 3700, 3701, 3702, 3703, 3704, 3705, 3706, 3707, 3708, 3709, 3710, 3711, 3712, 3713, 3714, 3715, 3717, 3718, 3719, 3720, 3721, 3722, 3723, 3724, 3725, 3726, 3727, 3728, 3729, 3730, 3731, 3732, 3733, 3734, 3735, 3736, 3737, 3738, 3739, 3740, 3741, 3742, 3743, 3744, 3745, 3746, 3747, 3748, 3749, 3750, 3751, 3752, 3753, 3754, 3755, 3756, 3757, 3758, 3759, 3760, 3761, 3762, 3763, 3764, 3765, 3766, 3767, 3768, 3769, 3770, 3771, 3772, 3773, 3774, 3775, 3776, 3778, 3779, 3780, 3781, 3782, 3783, 3784, 3785, 3786, 3787, 3788, 3789, 3790, 3791, 3792, 3793, 3794, 3795, 3796, 3797, 3798, 3799, 3800, 3801, 3802, 3803, 3804, 3805, 3806, 3807, 3808, 3809, 3810, 3811, 3812, 3813, 3814, 3815, 3816, 3817, 3818, 3819, 3820, 3821, 3822, 3823, 3824, 3825, 3826, 3827, 3828, 3829, 3830, 3831, 3832, 3833, 3834, 3836, 3837, 3838, 3839, 3840, 3841, 3842, 3843, 3844, 3845, 3846, 3847, 3848, 3850, 3851, 3852, 3853, 3854, 3855, 3856, 3857, 3858, 3859, 3860, 3861, 3862, 3863, 3864, 3865, 3866, 3867, 3868, 3869, 3870, 3871, 3872, 3873, 3874, 3875, 3876, 3877, 3878, 3879, 3880, 3881, 3882, 3883, 3884, 3885, 3886, 3887, 3888, 3889, 3890, 3891, 3892, 3893, 3894, 3895, 3896, 3897, 3898, 3899, 3900, 3901, 3902, 3903, 3904, 3905, 3906, 3907, 3908, 3909, 3910, 3911, 3912, 3913, 3914, 3915, 3916, 3917, 3918, 3919, 3920, 3921, 3922, 3923, 3924, 3925, 3926, 3927, 3928, 3929, 3930, 3931, 3932, 3933, 3934, 3935, 3936, 3937, 3938, 3939, 3940, 3941, 3942, 3943, 3944, 3945, 3946, 3947, 3948, 3949, 3950, 3951, 3952, 3953, 3954, 3955, 3956, 3957, 3958, 3959, 3960, 3961, 3962, 3963, 3964, 3965, 3966, 3967, 3968, 3969, 3970, 3971, 3972, 3973, 3974, 3975, 3976, 3977, 3978, 3979, 3980, 3981, 3982, 3983, 3984, 3985, 3986, 3987, 3988, 3989, 3990, 3991, 3992, 3993, 3994, 3995, 3996, 3997, 3998, 3999, 4000, 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 4009, 4010, 4011, 4012, 4013, 4014, 4015, 4016, 4017, 4018, 4019, 4020, 4021, 4022, 4023, 4024, 4025, 4026, 4027, 4028, 4029, 4030, 4031, 4032, 4033, 4034, 4035, 4036, 4037, 4038, 4039, 4040, 4041, 4042, 4043, 4044, 4045, 4046, 4047, 4048, 4049, 4050, 4051, 4053, 4054, 4055, 4056, 4057, 4058, 4059, 4060, 4061, 4062, 4063, 4064, 4065, 4066, 4067, 4068, 4069, 4070, 4071, 4072, 4073, 4074, 4075, 4076, 4077, 4078, 4079, 4080, 4081, 4082, 4083, 4084, 4085, 4086, 4087, 4088, 4089, 4090, 4091, 4092, 4093, 4094, 4095, 4096, 4097, 4098, 4099, 4100, 4101, 4102, 4103, 4104, 4105, 4106, 4107, 4108, 4109, 4110, 4111, 4112, 4113, 4114, 4115, 4116, 4117, 4118, 4119, 4120, 4121, 4122, 4123, 4124, 4125, 4126, 4127, 4128, 4129, 4130, 4131, 4132, 4133, 4134, 4135, 4136, 4137, 4138, 4139, 4140, 4141, 4142, 4143, 4144, 4145, 4146, 4147, 4148, 4149, 4150, 4151, 4152, 4153, 4154, 4155, 4156, 4157, 4158, 4159, 4160, 4161, 4162, 4163, 4164, 4165, 4166, 4167, 4168, 4169, 4170, 4171, 4172, 4173, 4174, 4175, 4176, 4177, 4178, 4179, 4180, 4181, 4182, 4183, 4184, 4185, 4186, 4187, 4188, 4189, 4190, 4191, 4192, 4193, 4194, 4195, 4196, 4197, 4198, 4199, 4200, 4201, 4202, 4203, 4204, 4205, 4206, 4207, 4208, 4209, 4210, 4211, 4212, 4213, 4214, 4215, 4216, 4217, 4218, 4219, 4220, 4221, 4222, 4223, 4224, 4225, 4226, 4227, 4228, 4229, 4230, 4231, 4232, 4233, 4234, 4235, 4236, 4237, 4238, 4239, 4240, 4241, 4242, 4243, 4244, 4245, 4246, 4247, 4248, 4249, 4250, 4251, 4252, 4253, 4254, 4255, 4256, 4257, 4258, 4259, 4260, 4261, 4262, 4263, 4264, 4265, 4266, 4267, 4268, 4269, 4270, 4271, 4272, 4273, 4274, 4275, 4276, 4277, 4278, 4279, 4280, 4281, 4282, 4283, 4284, 4285, 4286, 4287, 4288, 4289, 4290, 4291, 4292, 4293, 4294, 4295, 4296, 4297, 4299, 4300, 4301, 4302, 4303, 4304, 4305, 4306, 4307, 4308, 4309, 4310, 4311, 4312, 4313, 4314, 4315, 4316, 4317, 4318, 4319, 4320, 4321, 4322, 4323, 4324, 4325, 4326, 4327, 4328, 4330, 4334, 4335, 4337, 4338, 4342, 4345, 4346, 4355, 4356, 4357, 4359, 4361, 4362, 4364, 4374, 4385, 4386, 4391, 4392, 4394, 4395, 4402, 4403, 4405, 4411, 4415, 4416, 4418, 4419, 4420, 4421, 4422, 4423, 4424, 4425, 4426, 4427, 4428, 4429, 4430, 4431, 4432, 4433, 4434, 4435, 4436, 4437, 4438, 4439, 4440, 4441, 4442, 4443, 4445, 4446, 4447, 4448, 4449, 4450, 4451, 4452, 4453, 4454, 4455, 4456, 4457, 4458, 4459, 4460, 4461, 4462, 4463, 4464, 4465, 4466, 4467, 4468, 4469, 4470, 4471, 4472, 4473, 4474, 4475, 4476, 4477, 4478, 4479, 4480, 4481, 4482, 4483, 4484, 4485, 4486, 4487, 4488, 4489, 4490, 4492, 4493, 4494, 4495, 4496, 4497, 4498, 4499, 4500, 4501, 4502, 4503, 4504, 4505, 4506, 4507, 4508, 4509, 4510, 4511, 4512, 4513, 4514, 4515, 4516, 4517, 4518, 4519, 4520, 4521, 4522, 4523, 4524, 4525, 4526, 4527, 4528, 4529, 4530, 4531, 4532, 4533, 4534, 4535, 4536, 4537, 4538, 4539, 4540, 4541, 4542, 4543, 4544, 4545, 4546, 4547, 4548, 4549, 4550, 4551, 4552, 4553, 4555, 4558, 4559, 4561, 4562, 4564, 4565, 4566, 4567, 4568, 4569, 4570, 4572, 4573, 4574, 4575, 4576, 4579, 4581, 4582, 4583, 4584, 4585, 4586, 4587, 4588, 4589, 4590, 4592, 4593, 4594, 4596, 4598, 4599, 4601, 4602, 4605, 4607, 4608, 4609, 4610, 4612, 4614, 4619, 4620, 4622, 4623, 4624, 4625, 4626, 4627, 4628, 4630, 4631, 4632, 4633, 4634, 4635, 4637, 4639, 4640, 4641, 4642, 4643, 4645, 4647, 4648, 4649, 4651, 4652, 4654, 4656, 4658, 4659, 4660, 4661, 4662, 4663, 4667, 4669, 4670, 4672, 4673, 4674, 4675, 4676, 4677, 4678, 4679, 4681, 4683, 4684, 4685, 4686, 4687, 4689, 4690, 4691, 4692, 4693, 4694, 4696, 4697, 4698, 4700, 4701, 4702, 4704, 4705, 4708, 4710, 4712, 4713, 4714, 4715, 4716, 4717, 4718, 4719, 4720, 4721, 4722, 4723, 4724, 4725, 4726, 4727, 4728, 4729, 4730, 4731, 4732, 4733, 4734, 4735, 4736, 4737, 4738, 4739, 4740, 4741, 4742, 4743, 4744, 4745, 4746, 4747, 4750, 4751, 4752, 4753, 4754, 4756, 4758, 4759, 4761, 4762, 4763, 4764, 4765, 4766, 4769, 4770, 4772, 4773, 4774, 4776, 4777, 4778, 4779, 4780, 4781, 4782, 4783, 4784, 4785, 4786, 4788, 4789, 4790, 4792, 4793, 4794, 4797, 4798, 4799, 4800, 4801, 4806, 4807, 4808, 4809, 4810, 4811, 4812, 4814, 4816, 4817, 4818, 4821, 4823, 4824, 4825, 4826, 4827, 4828, 4829, 4830, 4831, 4832, 4833, 4834, 4835, 4836, 4837, 4838, 4839, 4840, 4841, 4842, 4843, 4844, 4845, 4846, 4847, 4848, 4849, 4851, 4852, 4853, 4854, 4855, 4856, 4857, 4858, 4859, 4860, 4861, 4862, 4863, 4864, 4865, 4866, 4867, 4868, 4869, 4870, 4871, 4873, 4874, 4875, 4876, 4877, 4878, 4879, 4880, 4881, 4882, 4883, 4884, 4885, 4886, 4887, 4888, 4889, 4890, 4891, 4892, 4893, 4894, 4896, 4897, 4898, 4899, 4900, 4901, 4902, 4903, 4904, 4906, 4908, 4910, 4912, 4913, 4914, 4916, 4917, 4919, 4920, 4921, 4922, 4924, 4925, 4926, 4927, 4928, 4929, 4930, 4931, 4932, 4935, 4936, 4937, 4938, 4939, 4942, 4943, 4944, 4945, 4946, 4947, 4948, 4949, 4950, 4951, 4952, 4953, 4954, 4955, 4956, 4957, 4958, 4959, 4960, 4961, 4962, 4963, 4964, 4966, 4967, 4968, 4969, 4970, 4971, 4972, 4973, 4974, 4975, 4976, 4977, 4978, 4979, 4980, 4981, 4982, 4983, 4984, 4985, 4986, 4988, 4989, 4990, 4991, 4992, 4993, 4994, 4995, 4996, 4997, 4998, 4999, 5000, 5001, 5002, 5003, 5004, 5009, 5010, 5011, 5012, 5013, 5014, 5015, 5017, 5018, 5019, 5020, 5021, 5022, 5023, 5024, 5025, 5026, 5027, 5028, 5029, 5030, 5031, 5032, 5034, 5035, 5036, 5037, 5038, 5039, 5040, 5041, 5042, 5044, 5049, 5050, 5051, 5053, 5055, 5056, 5058, 5059, 5060, 5061, 5062, 5063, 5064, 5065, 5066, 5067, 5070, 5074, 5075, 5076, 5077, 5078, 5079, 5080, 5081, 5083, 5084, 5085, 5086, 5087, 5088, 5089, 5090, 5091, 5092, 5093, 5094, 5095, 5096, 5097, 5098, 5099, 5100, 5101, 5102, 5103, 5104, 5105, 5106, 5107, 5108, 5109, 5110, 5111, 5112, 5113, 5114, 5115, 5116, 5117, 5118, 5119, 5120, 5121, 5122, 5123, 5124, 5125, 5126, 5127, 5128, 5129, 5130, 5131, 5132, 5133, 5134, 5135, 5136, 5137, 5138, 5140, 5141, 5142, 5143, 5144, 5146, 5148, 5151, 5152, 5153, 5154, 5155, 5156, 5161, 5162, 5164, 5165, 5166, 5167, 5168, 5173, 5174, 5176, 5177, 5178, 5179, 5180, 5181, 5182, 5183, 5184, 5185, 5186, 5187, 5190, 5191, 5192, 5193, 5194, 5195, 5196, 5197, 5198, 5199, 5201, 5203, 5205, 5207, 5208, 5209, 5210, 5211, 5212, 5213, 5214, 5215, 5216, 5217, 5218, 5219, 5220, 5221, 5222, 5223, 5224, 5226, 5227, 5229, 5230, 5231, 5233, 5234, 5235, 5236, 5237, 5238, 5240, 5241, 5242, 5243, 5244, 5246, 5247, 5248, 5249, 5250, 5251, 5253, 5255, 5256, 5257, 5258, 5259, 5260, 5261, 5262, 5263, 5264, 5265, 5266, 5267, 5268, 5269, 5271, 5272, 5273, 5274, 5275, 5276, 5278, 5279, 5280, 5285, 5288, 5289, 5290, 5291, 5292, 5293, 5294, 5295, 5296, 5297, 5298, 5299, 5300, 5301, 5302, 5303, 5304, 5305, 5306, 5307, 5308, 5309, 5310, 5311, 5312, 5313, 5314, 5316, 5317, 5318, 5319, 5321, 5322, 5323, 5324, 5325, 5326, 5327, 5329, 5330, 5331, 5332, 5333, 5334, 5335, 5336, 5338, 5339, 5340, 5341, 5342, 5343, 5344, 5345, 5346, 5347, 5348, 5349, 5350, 5351, 5352, 5355, 5356, 5357, 5359, 5361, 5362, 5363, 5364, 5365, 5366, 5368, 5369, 5370, 5371, 5372, 5373, 5374, 5375, 5376, 5377, 5378, 5379, 5380, 5381, 5382, 5383, 5384, 5385, 5386, 5389, 5390, 5391, 5392, 5393, 5394, 5396, 5397, 5398, 5399, 5400, 5401, 5403, 5404, 5405, 5406, 5407, 5408, 5410, 5411, 5412, 5414, 5418, 5419, 5420, 5421, 5422, 5423, 5424, 5425, 5426, 5427, 5428, 5429, 5430, 5432, 5433, 5434, 5435, 5436, 5437, 5438, 5439, 5440, 5441, 5442, 5443, 5444, 5445, 5446, 5447, 5448, 5449, 5450, 5451, 5452, 5454, 5455, 5456, 5457, 5458, 5459, 5460, 5464, 5465, 5466, 5467, 5468, 5469, 5470, 5471, 5472, 5474, 5475, 5476, 5477, 5478, 5479, 5480, 5481, 5482, 5483, 5484, 5485, 5487, 5489, 5490, 5491, 5492, 5493, 5495, 5497, 5498, 5499, 5500, 5501, 5503, 5504, 5505, 5506, 5507, 5508, 5511, 5514, 5515, 5516, 5517, 5518, 5519, 5520, 5521, 5522, 5523, 5524, 5525, 5526, 5527, 5528, 5529, 5530, 5531, 5532, 5533, 5534, 5535, 5536, 5537, 5538, 5539, 5540, 5541, 5542, 5543, 5544, 5545, 5546, 5547, 5548, 5549, 5550, 5551, 5552, 5553, 5555, 5556, 5557, 5558, 5559, 5560, 5561, 5562, 5563, 5564, 5566, 5567, 5568, 5569, 5570, 5571, 5572, 5573, 5574, 5575, 5576, 5577, 5578, 5579, 5581, 5582, 5583, 5584, 5585, 5587, 5589, 5590, 5591, 5592, 5593, 5594, 5595, 5597, 5598, 5599, 5600, 5601, 5602, 5603, 5605, 5606, 5608, 5609, 5611, 5612, 5613, 5614, 5615, 5616, 5617, 5618, 5619, 5620, 5621, 5622, 5623, 5624, 5625, 5626, 5627, 5628, 5629, 5630, 5631, 5632, 5633, 5634, 5635, 5636, 5637, 5638, 5639, 5640, 5641, 5642, 5643, 5644, 5645, 5646, 5647, 5648, 5649, 5650, 5652, 5653, 5654, 5655, 5656, 5657, 5658, 5659, 5660, 5661, 5662, 5663, 5664, 5665, 5666, 5667, 5668, 5669, 5670, 5671, 5672, 5674, 5675, 5676, 5678, 5680, 5681, 5683, 5684, 5686, 5687, 5688, 5690, 5691, 5692, 5693, 5694, 5695, 5696, 5698, 5699, 5700, 5701, 5704, 5705, 5706, 5707, 5708, 5709, 5710, 5711, 5712, 5713, 5714, 5715, 5717, 5718, 5719, 5720, 5721, 5722, 5723, 5724, 5725, 5726, 5727, 5728, 5729, 5731, 5732, 5734, 5735, 5736, 5737, 5739, 5741, 5742, 5743, 5744, 5745, 5746, 5747, 5748, 5749, 5750, 5751, 5752, 5753, 5754, 5755, 5756, 5757, 5758, 5760, 5761, 5762, 5764, 5765, 5767, 5768, 5769, 5770, 5771, 5772, 5773, 5774, 5775, 5776, 5777, 5778, 5781, 5783, 5785, 5786, 5787, 5788, 5789, 5790, 5791, 5792, 5793, 5794, 5795, 5796, 5797, 5798, 5799, 5800, 5801, 5803, 5804, 5806, 5807, 5809, 5810, 5811, 5812, 5813, 5814, 5815, 5817, 5818, 5819, 5820, 5821, 5822, 5824, 5825, 5826, 5827, 5828, 5829, 5830, 5833, 5834, 5835, 5836, 5839, 5840, 5841, 5842, 5843, 5844, 5845, 5846, 5847, 5848, 5852, 5853, 5854, 5857, 5858, 5859, 5861, 5862, 5863, 5866, 5869, 5870, 5871, 5872, 5874, 5875, 5876, 5879, 5880, 5882, 5883, 5884, 5887, 5889, 5890, 5891, 5892, 5894, 5896, 5897, 5898, 5899, 5900, 5901, 5902, 5905, 5907, 5909, 5910, 5911, 5912, 5913, 5914, 5915, 5916, 5918, 5919, 5922, 5923, 5925, 5926, 5927, 5928, 5929, 5930, 5931, 5932, 5933, 5936, 5942, 5943, 5944, 5945, 5946, 5948, 5949, 5950, 5953, 5954, 5955, 5959, 5960, 5962, 5963, 5966, 5969, 5970, 5972, 5973, 5977, 5979, 5980, 5981, 5982, 5983, 5984, 5986, 5990, 5992, 5994, 5995, 5996, 5997, 5998, 5999, 6001, 6004, 6005, 6008, 6010, 6012, 6013, 6014, 6017, 6018, 6020, 6023, 6024, 6026, 6027, 6029, 6030, 6031, 6032, 6034, 6036, 6037, 6041, 6045, 6048, 6049, 6050, 6051, 6053, 6056, 6057, 6058, 6061, 6062, 6063, 6065, 6068, 6069, 6070, 6072, 6073, 6075, 6076, 6077, 6078, 6080, 6082, 6084, 6086, 6090, 6091, 6094, 6095, 6099, 6100, 6103, 6107, 6108, 6111, 6117, 6118, 6119, 6121, 6122, 6124, 6125, 6126, 6133, 6135, 6136, 6137, 6138, 6139, 6144, 6145, 6147, 6151, 6152, 6153, 6154, 6155, 6156, 6158, 6159, 6160, 6161, 6162, 6163, 6164, 6165, 6167, 6168, 6170, 6171, 6172, 6173, 6174, 6175, 6176, 6177, 6178, 6179, 6180, 6181, 6182, 6183, 6184, 6185, 6186, 6187, 6188, 6189, 6190, 6191, 6196, 6197, 6200, 6203, 6204, 6209, 6211, 6212, 6213, 6214, 6215, 6216, 6217, 6218, 6219, 6222, 6223, 6224, 6226, 6227, 6228, 6232, 6233, 6234, 6235, 6239, 6240, 6241, 6243, 6244, 6246, 6247, 6251, 6252, 6254, 6255, 6257, 6258, 6262, 6263, 6265, 6266, 6269, 6270, 6274, 6276, 6279, 6281, 6283, 6295, 6297, 6298, 6302, 6305, 6308, 6309, 6310, 6323, 6333, 6335, 6336, 6338, 6340, 6341, 6344, 6345, 6348, 6355, 6364, 6370, 6378, 6381, 6382]


BEG = 3080
TOTAL = len(movies) - BEG
END = BEG + TOTAL

import subprocess as sp

parent_directory = sp.getoutput('pwd')

folder_name = str(BEG) + '-' + str(END-1)

! mkdir $folder_name
# %cd $folder_name

current_directory = sp.getoutput('pwd')

# Commented out IPython magic to ensure Python compatibility.
with tqdm(total=(TOTAL)) as pbar:
  for movie in  movies[BEG:END] :
    malayalachalachitram(movie=movie)
    pbar.update(1)

films = list(dict.fromkeys(films))
Esempio n. 56
0
 def executeAndReturnOutput(self, commandStr):
     self._log.debug("Executing '%s'" % commandStr)
     return subprocess.getoutput(self._splitCommandStr(commandStr)).strip()
Esempio n. 57
0
def main():
	parser = argparse.ArgumentParser(description='ICN-Stage experiments plotter')

	help_msg = "logging level (INFO=%d DEBUG=%d)" % (logging.INFO, logging.DEBUG)
	parser.add_argument("--log", "-l", help=help_msg, default=DEFAULT_LOG_LEVEL, type=int)

	help_msg = "outputfile (default={})".format(DEFAULT_OUT_FILE_NAME)
	parser.add_argument("--out", "-o", help=help_msg, default=DEFAULT_OUT_FILE_NAME, type=str)

	help_msg = "input_file_1 input_file_2 ... input_file_N "
	parser.add_argument('files', type=str, help=help_msg, nargs=argparse.ONE_OR_MORE)

	help_msg = "x axis Experiment length (secs) "
	parser.add_argument("--xlim", "-x", help=help_msg, default=X_LIM, type=int)

	help_msg = "y axis Bandwidth (Mbits/sec)"
	parser.add_argument("--ylim", "-y", help=help_msg, default=Y_LIM, type=float)

	help_msg = "type [iperf|ndn]"
	parser.add_argument("--type", "-t", help=help_msg, default=DEFAULT_TYPE, type=str)

	# read arguments from the command line
	args = parser.parse_args()

	# setup the logging facility
	if args.log == logging.DEBUG:
		logging.basicConfig(format='%(asctime)s %(levelname)s {%(module)s} [%(funcName)s] %(message)s',
							datefmt=TIME_FORMAT, level=args.log)

	else:
		logging.basicConfig(format='%(asctime)s %(message)s',
							datefmt=TIME_FORMAT, level=args.log)

	logging.info("")
	logging.info("INPUT")
	logging.info("---------------------")
	logging.info("\t logging level : {}".format(args.log))
	logging.info("\t xlim          : {}".format(args.xlim))
	logging.info("\t ylim          : {}".format(args.ylim))
	logging.info("\t out           : {}".format(args.out))
	logging.info("\t type          : {}".format(args.type))
	logging.info("\t files         : {}".format(args.files))
	logging.info("")

	logging.info("Reading files")
	logging.info("-------------")
	print("")

	data_set = {}
	for filename in args.files:

		logging.info("file name   : {}".format(filename))
		cmd = """awk -F'[ -]+' '/sec/{print $1,$9}' %s""" % filename

		if args.type == "ndn":
			cmd = """awk  '/Interest received/{print $2,$7}' %s""" % filename

		logging.info("cmd         : {}".format(cmd))
		result_process = subprocess.getoutput(cmd)
		result_data = result_process.split("\n")
		logging.info("\tprocessing...")
		x_axis, y_axis = process_sum(result_data, args.type)
		data_set[filename] = (x_axis, y_axis)
		print("")

	logging.info("Plotting")
	logging.info("--------")
	plot_bar(data_set, args.out, args.xlim, args.ylim, args.type)
Esempio n. 58
0
 def _main(self):
     ret = subprocess.getoutput(self.command)
     self.complete(ret)
     self.valid(ret)
     self.status = True
from ase.data import atomic_numbers, covalent_radii
from hotcent.atomic_dft import AtomicDFT
from hotcent.confinement import PowerConfinement
from hotcent.tools import ConfinementOptimizer, DftbPlusBandStructure

#import command #python2
import subprocess #python3
import sys
import ast

#read cif file
import ase.io

element = 'Re'
#elem_data = commands.getoutput("awk '{if($1==\""+str(element)+"\"{print $0}}' gpaw_table") #python2
elem_data = subprocess.getoutput("awk '{if($1==\""+str(element)+"\"){print $0}}' gpaw_table") #python3
elem_list = elem_data.split(" | ")

element = elem_list[0]
print("element = ",element)
struct = elem_list[1]
print("struct = ",struct)
nkpts = elem_list[4]
print("kpts = ",nkpts)
kpts = ast.literal_eval(nkpts)

#elem_data = commands.getoutput("awk '{if($1==\""+str(element)+"\"{print $0}}' table_fit") #python2
elem_data = subprocess.getoutput("awk '{if($1==\""+str(element)+"\"){print $0}}' table_fit") #python3
elem_list = elem_data.split(" | ")

#element = 'Si'
Esempio n. 60
0
def _root():
    """Returns root directory of git project repository"""
    cmd = 'git rev-parse --show-toplevel 2>/dev/null'
    return subprocess.getoutput(cmd).strip()