Пример #1
0
 def do_transfer(self, filename, servername, remotedir, userinfo):
     getfile.getfile(filename,
                     servername,
                     remotedir,
                     userinfo,
                     verbose=False,
                     refetch=True)
Пример #2
0
def log_qdisc_stats(file_prefix='', remote_dir='', local_dir='.'):
    "Get qdisc statistics after experiment"

    if remote_dir != '' and remote_dir[-1] != '/':
        remote_dir += '/'

    file_name = remote_dir + file_prefix + "_" + \
        env.host_string.replace(":", "_") + "_qdisc_stats.log"

    getfile(file_name, local_dir)
Пример #3
0
def log_queue_stats(file_prefix='', remote_dir='', local_dir='.'):
    "Get queue statistics after experiment"

    if remote_dir != '' and remote_dir[-1] != '/':
        remote_dir += '/'

    # get host type
    htype = get_type_cached(env.host_string)

    file_name = remote_dir + file_prefix + "_" + \
        env.host_string.replace(":", "_") + "_queue_stats.log"

    if htype == 'FreeBSD':
        run('sudo echo ipfw pipe show > %s' % file_name)
        run('sudo ipfw pipe show >> %s' % file_name)
        run('sudo echo ipfw show >> %s' % file_name)
        run('sudo ipfw show >> %s' % file_name)
    elif htype == 'Linux':
        run('sudo echo tc -d -s qdisc show > %s' % file_name)
        run('sudo tc -d -s qdisc show >> %s' % file_name)

        #        interfaces = get_netint_cached(env.host_string, int_no=-1)
        #        interfaces[0] = 'eno1' # swapna
        #        interfaces[1] = 'enx000000000f92' # swapna
        cnt = 0
        for interface in interfaces:
            run('sudo echo >> %s' % file_name)
            run('sudo echo tc -s class show dev %s >> %s' %
                (interface, file_name))
            run('sudo tc -s class show dev %s >> %s' % (interface, file_name))
            run('sudo echo >> %s' % file_name)
            run('sudo echo tc -s filter show dev %s >> %s' %
                (interface, file_name))
            run('sudo tc -s filter show dev %s >> %s' % (interface, file_name))
            pseudo_interface = 'ifb' + str(cnt)
            run('sudo echo >> %s' % file_name)
            run('sudo echo tc -d -s class show dev %s >> %s' %
                (pseudo_interface, file_name))
            run('sudo tc -d -s class show dev %s >> %s' %
                (pseudo_interface, file_name))
            run('sudo echo >> %s' % file_name)
            run('sudo echo tc -d -s filter show dev %s >> %s' %
                (pseudo_interface, file_name))
            run('sudo tc -d -s filter show dev %s >> %s' %
                (pseudo_interface, file_name))
            cnt += 1

        run('sudo echo iptables -t mangle -vL >> %s' % file_name)
        run('sudo iptables -t mangle -vL >> %s' % file_name)

    getfile(file_name, local_dir)
Пример #4
0
def stop_tcp_logger(file_prefix='', remote_dir='', local_dir='.'):
    "Stop TCP logger (e.g. siftr on FreeBSD)"

    # get host type
    htype = get_type_cached(env.host_string)

    if htype == 'FreeBSD':
        run('sysctl net.inet.siftr.enabled=0')
        run('kldunload siftr')
        logfile = file_prefix + '_' + \
            env.host_string.replace(':', '_') + '_siftr.log'

    elif htype == 'Linux':
        #run('killall web100_logger')
        run('killall web100-logger')
        logfile = file_prefix + '_' + \
            env.host_string.replace(':', '_') + '_web10g.log'

    elif htype == 'Darwin':
        pass

    elif htype == 'CYGWIN':
        run('killall win-estats-logger')
        logfile = file_prefix + '_' + \
            env.host_string.replace(':', '_') + '_web10g.log'

    if logfile == '':
        if remote_dir != '':
            logfile = remote_dir + '/' + logfile

    if file_prefix != '' or remote_dir != '':
        file_name = logfile
    else:
        file_name = bgproc.get_proc_log(env.host_string, 'tcplogger', '00')

    # add a small delay to allow logger to write data to disk completely
    time.sleep(0.5)

    # commented out: I think it may be confusing if the stats not match etc.
    # if htype == 'FreeBSD':
    # filter out control traffic from siftr log but
    # stats and flow list in last line of log is left unchanged
    #host = env.host_string.split(':')[0]
    #tmp_file = local('mktemp "tmp.XXXXXXXXXX"', capture=True)
    # run('cat %s | grep -v ",%s," > %s && mv %s %s' % \
    #    (file_name, host, tmp_file, tmp_file, file_name))

    getfile(file_name, local_dir)
    bgproc.remove_proc(env.host_string, 'tcplogger', '00')
Пример #5
0
def log_queue_stats(file_prefix='', remote_dir='', local_dir='.'):
    "Get queue statistics after experiment"

    if remote_dir != '' and remote_dir[-1] != '/':
        remote_dir += '/'

    # get host type
    htype = get_type_cached(env.host_string)

    file_name = remote_dir + file_prefix + "_" + \
        env.host_string.replace(":", "_") + "_queue_stats.log"

    if htype == 'FreeBSD':
        run('echo ipfw pipe show > %s' % file_name)
        run('ipfw pipe show >> %s' % file_name)
        run('echo ipfw show >> %s' % file_name)
        run('ipfw show >> %s' % file_name)
    elif htype == 'Linux':
        run('echo tc -d -s qdisc show > %s' % file_name)
        run('tc -d -s qdisc show >> %s' % file_name)

        interfaces = get_netint_cached(env.host_string, int_no=-1)
        cnt = 0
        for interface in interfaces:
            run('echo >> %s' % file_name)
            run('echo tc -s class show dev %s >> %s' % (interface, file_name))
            run('tc -s class show dev %s >> %s' % (interface, file_name))
            run('echo >> %s' % file_name)
            run('echo tc -s filter show dev %s >> %s' % (interface, file_name))
            run('tc -s filter show dev %s >> %s' % (interface, file_name))
            pseudo_interface = 'ifb' + str(cnt)
            run('echo >> %s' % file_name)
            run('echo tc -d -s class show dev %s >> %s' %
                (pseudo_interface, file_name))
            run('tc -d -s class show dev %s >> %s' %
                (pseudo_interface, file_name))
            run('echo >> %s' % file_name)
            run('echo tc -d -s filter show dev %s >> %s' %
                (pseudo_interface, file_name))
            run('tc -d -s filter show dev %s >> %s' %
                (pseudo_interface, file_name))
            cnt += 1

        run('echo iptables -t mangle -vL >> %s' % file_name)
        run('iptables -t mangle -vL >> %s' % file_name)

    getfile(file_name, local_dir)
Пример #6
0
def get_file_dir_share():
    id = request.cookies.get('key')
    updir = os.path.join(basedir,
                         'static/uploads/' + session[id]['mis'] + '/share')
    return json.dumps({
        'dir': getfile.getdir(updir),
        'file': getfile.getfile(updir)
    })
def plot(vfiles,sc,start_date,end_date,dirs,colours,legends,plotwhichs):
    global prune_start,prune_end,prune_n
    if start_date==end_date or end_date=='':
        dates = start_date
    else:
        dates = [start_date+timedelta(days=1)*i for i in range(abs(end_date-start_date).days)]
    for datev in dates:
        print ""
        print datev.isoformat()
        Year = str(datev.year)
        #year = Year[2:4]
        month = '{0:02d}'.format(datev.month)
        day = '{0:02d}'.format(datev.day)

        for [dir,ext],colour,legend,plotwhich in zip(dirs,colours,legends,plotwhichs):
            directory = dir+Year+'/'+month+'/'
            if 'Y:' in directory:
                file = getfile(sc,Year,month,day,directory,ext=True)
            else:
                file = getfile(sc,Year,month,day,directory)

            if file:
                print "filefound:",file
                vlist = vectorlist()
                vlist.read_file(file)
                vfiles.add_vectorlist(vlist,colour,legend,plotwhich)
                #vlist.print_values(0)
            
    #vfiles.printfiles()
    if 'x' in plotwhichs or 'y' in plotwhichs or 'z' in plotwhichs:
        log=False
    else:
        log=True
        
    if prune_start != datetime(1,1,1) and prune_end != datetime(1,1,1):
        print "Pruning Dates"
        vfiles.prune(start_date=prune_start,end_date=prune_end)
    if prune_n > 1:
        print "Pruning Points"
        vfiles.prune(n=prune_n)
    vfiles.plotfiles(scatter=True,log=log)
Пример #8
0
def get_dir():
    id = request.cookies.get('key')
    src = request.form['dir']
    if id in session:
        updir = src
        return json.dumps({
            'dir': getfile.getdir(updir),
            'file': getfile.getfile(updir),
            'mis': session[id]['mis']
        })
        return render_template('error.html')
    return render_template('no_login.html')
Пример #9
0
def stop_tcpdump(file_prefix='', remote_dir='', local_dir='.'):
    "Stop tcpdump instance on host"

    pid = bgproc.get_proc_pid(env.host_string, 'tcpdump', '0')
    with settings(warn_only=True):
        if pid != "":
            run('kill %s' % pid, pty=False)
        else:
            # get host type
            htype = get_type_cached(env.host_string)
            if htype == "FreeBSD" or htype == "Linux" or htype == 'Darwin':
                run('killall tcpdump')
            else:
                run('killall WinDump', pty=False)

    if file_prefix != "" or remote_dir != "":
        file_name = remote_dir + file_prefix + "_" + \
            env.host_string.replace(":", "_") + ".dmp"
    else:
        file_name = bgproc.get_proc_log(env.host_string, 'tcpdump', '0')

    getfile(file_name, local_dir)
    bgproc.remove_proc(env.host_string, 'tcpdump', '0')
Пример #10
0
def stop_tcpdump(file_prefix='', remote_dir='', local_dir='.'):
    "Stop tcpdump instance on host"

    pid = bgproc.get_proc_pid(env.host_string, 'tcpdump', '0')
    with settings(warn_only=True):
        if pid != "":
            run('kill %s' % pid, pty=False)
        else:
            # get host type
            htype = get_type_cached(env.host_string)
            if htype == "FreeBSD" or htype == "Linux" or htype == 'Darwin':
                run('killall tcpdump')
            else:
                run('killall WinDump', pty=False)

    if file_prefix != "" or remote_dir != "":
        file_name = remote_dir + file_prefix + "_" + \
            env.host_string.replace(":", "_") + ".dmp"
    else:
        file_name = bgproc.get_proc_log(env.host_string, 'tcpdump', '0')

    getfile(file_name, local_dir)
    bgproc.remove_proc(env.host_string, 'tcpdump', '0')
def process(vfiles,sc,start_date,end_date,input):
    global prune_start,prune_end,prune_n,prune_value
    dirs = [[entry[0],entry[1]] for entry in input]
    colours = [entry[2] for entry in input]
    legends = [entry[3] for entry in input]
    plotwhichs=[entry[4] for entyr in input] 
    if start_date==end_date or end_date=='':
        dates = start_date
    else:
        dates = [start_date+timedelta(days=1)*i for i in range(abs(end_date-start_date).days)]
    for datev in dates:
        print ""
        print datev.isoformat()
        Year = str(datev.year)
        #year = Year[2:4]
        month = '{0:02d}'.format(datev.month)
        day = '{0:02d}'.format(datev.day)

        for [dir,ext],colour,legend,plotwhich in zip(dirs,colours,legends,plotwhichs):
            directory = dir+Year+'/'+month+'/'
            print "Getting file:",sc,Year,month,day,directory,ext
            file = getfile(sc,Year,month,day,directory,ext=ext)

            if file:
                print "filefound:",file
                vlist = vectorlist()
                vlist.read_file(file)
                vfiles.add_vectorlist(vlist,colour,legend,plotwhich)
                #vlist.print_values(0)
    print "Prune Start"
    if prune_start != datetime(1,1,1) and prune_end != datetime(1,1,1):
        print "Pruning Dates"
        vfiles.prune(start_date=prune_start,end_date=prune_end)
    if prune_n > 1:
        print "Pruning Points"
        vfiles.prune(n=prune_n)
    if prune_value > 0:
        print "Pruning Values"
        vfiles.prune(value=prune_value)
 def do_transfer(self, filename, servername, remotedir, userinfo):
     getfile.getfile(filename, servername, remotedir, userinfo, 0, 1)
#!/usr/local/bin/python


import getfile
from getpass import getpass
filename = 'monkeys.jpg'

# fetch with utility
getfile.getfile(file=filename,
                site='ftp.rmi.net',
                dir ='.',
                user=(),
                refetch=True)

# rest is the same
if input('Open file?') in ['Y', 'y']:
    from PP4E.System.Media.playfile import playfile
    playfile(filename)
Пример #14
0
        plt.yscale('log')
        #plt.xscale('log')
        plt.xlabel('bias (V)',size=25)
        plt.ylabel('J (A/${cm^2)}$',size=25)
        plt.xlim(-2,2)
        #plt.ylim(5e-13,2e-3)
        plt.grid(True)
        plt.plot(bias,Jabs)
        #plt.plot(Vrev,Jcorr)
        #plt.plot(bias,Jsh)
        plt.title('Donor/C60/LiF/Al',size=25)
        #plt.text(-2.8,1e-7,f'Jd @ -2V = {abs(J[bias.index(-2)]):.2e} A/cm²\nRsh = {Rsh:.2e} Ω/cm²\nRs = {Rs:.2e} Ω/cm²\n',fontsize=15,style='normal')
    matVoc=np.array(l)
    matjsc=np.array(ljsc)
    print(f'Voc = {np.mean(matVoc):.2f} ± {np.std(matVoc):.2f}({max(l):.2f}) V')
    print(f'Jlight @ -2V= {np.mean(matjsc)*1000:.2f} ± {np.std(matjsc)*1000:.2f} mA/cm²')
#输入文件夹及关键字,路径'\'用'/'代替
plt.figure(figsize = (16,9))
filetxt_list=getfile('jv/simulator/20200627','.dat','s6','52')
plotjv(filetxt_list)

filetxt_list=getfile('jv/simulator/20200627','.dat','s7','51')
plotjv(filetxt_list)

'''getfile('jv/ps-20200701','s2','0.01')
plotjv(filetxt_list)
getfile('jv/ps-20200701','s3','0.01')
plotjv(filetxt_list)
filetxt_list=[]'''

plt.show()
Пример #15
0
#!/usr/local/bin/python
"""
在脚本中使用getfile
A Python script to download and play a media file by FTP.
Uses getfile.py, a utility module which encapsulates FTP step.
"""

import getfile
from getpass import getpass
filename = 'monkeys.jpg'

# fetch with utility
getfile.getfile(file=filename,
                site='ftp.rmi.net',
                dir ='.',
                user=('lutz', getpass('Pswd?')),
                refetch=True)

# rest is the same
if input('Open file?') in ['Y', 'y']:
    from PP4E.System.Media.playfile import playfile
    playfile(filename)
Пример #16
0
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 30 15:57:36 2020

@author: yang30
"""

import pandas as pd
import matplotlib.pyplot as plt
from getfile import getfile

filetxt_list = getfile('eqe\eqe20200621', '.xlsx', '-2V', 's6')

#把符合条件的数据绘图

plt.xlabel('wavelength (nm)')
plt.ylabel('EQE (%)')
plt.xlim(400, 1050)
plt.ylim(0, 80)
plt.grid(True)

for file in filetxt_list:
    dfeqe = pd.read_excel(file)
    EQE = dfeqe.iloc[:, 1].tolist()
    wavelength = dfeqe.iloc[:, 0].tolist()

    plt.plot(wavelength, EQE, label=file)

plt.legend()
plt.show()
Пример #17
0
def log_sysdata(file_prefix='', remote_dir='', local_dir='.'):
    "Log various information for each system"

    if remote_dir != '' and remote_dir[-1] != '/':
        remote_dir += '/'

    # get host type
    htype = get_type_cached(env.host_string)

    file_name = remote_dir + file_prefix + "_" + \
        env.host_string.replace(":", "_") + "_uname.log"
    run('uname -a > %s' % file_name, pty=False)
    getfile(file_name, local_dir)

    file_name = remote_dir + file_prefix + "_" + \
        env.host_string.replace(":", "_") + "_netstat.log"
    run('netstat -nr > %s' % file_name, pty=False)
    getfile(file_name, local_dir)

    file_name = remote_dir + file_prefix + "_" + \
        env.host_string.replace(":", "_") + "_sysctl.log"
    if htype == 'FreeBSD' or htype == 'Linux' or htype == 'Darwin':
        run('sysctl -a > %s' % file_name)
    else:
        run('echo "netsh int show int" > %s' % file_name, pty=False)
        run('netsh int show int >> %s' % file_name, pty=False)
        run('echo "netsh int tcp show global" >> %s' % file_name, pty=False)
        run('netsh int tcp show global >> %s' % file_name, pty=False)
        run('echo "netsh int tcp show heuristics" >> %s' %
            file_name, pty=False)
        run('netsh int tcp show heuristics >> %s' % file_name, pty=False)
        run('echo "netsh int tcp show security" >> %s' % file_name, pty=False)
        run('netsh int tcp show security >> %s' % file_name, pty=False)
        run('echo "netsh int tcp show chimneystats" >> %s' %
            file_name, pty=False)
        run('netsh int tcp show chimneystats >> %s' % file_name, pty=False)
        run('echo "netsh int ip show offload" >> %s' % file_name, pty=False)
        run('netsh int ip show offload >> %s' % file_name, pty=False)
        run('echo "netsh int ip show global" >> %s' % file_name, pty=False)
        run('netsh int ip show global >> %s' % file_name, pty=False)

    getfile(file_name, local_dir)

    file_name = remote_dir + file_prefix + "_" + \
        env.host_string.replace(":", "_") + "_ifconfig.log"
    if htype == 'FreeBSD' or htype == 'Linux' or htype == 'Darwin':
        run('ifconfig -a > %s' % file_name)
    else:
        run('ipconfig > %s' % file_name, pty=False)
        # log interface speeds
        run('echo "wmic NIC where NetEnabled=true get Name, Speed" >> %s' % file_name, pty=False)
        run('wmic NIC where NetEnabled=true get Name, Speed >> %s' % file_name, pty=False)

    getfile(file_name, local_dir)

    file_name = remote_dir + file_prefix + "_" + \
        env.host_string.replace(":", "_") + "_procs.log"
    if htype == 'FreeBSD' or htype == 'Linux':
        run('ps -axu > %s' % file_name)
    elif htype == 'Darwin':
        run('ps -axu root > %s' % file_name)
    else:
        run('ps -alW > %s' % file_name, pty=False)

    getfile(file_name, local_dir)

    file_name = remote_dir + file_prefix + "_" + \
        env.host_string.replace(":", "_") + "_ntp.log"
    if htype == 'FreeBSD' or htype == 'Linux' or htype == 'Darwin':
        run('ntpq -4p > %s' % file_name)
    else:
        with settings(warn_only=True):
            # if we have ntp installed then use ntpq, otherwise use w32tm
            ret = run('ls "/cygdrive/c/Program Files (x86)/NTP/bin/ntpq"')
            if ret.return_code == 0:
                run('"/cygdrive/c/Program Files (x86)/NTP/bin/ntpq" -4p > %s' % 
                    file_name, pty=False)
            else:
                run('w32tm /query /status > %s' % file_name, pty=False)

    getfile(file_name, local_dir)

    # log tcp module parameters (Linux only)
    if htype == 'Linux':
        file_name = remote_dir + file_prefix + "_" + \
            env.host_string.replace(":", "_") + "_tcpmod.log"
        run("find /sys/module/tcp* -type f -exec grep -sH '' '{}' \; | "
            "grep -v Binary > %s" % file_name)
        getfile(file_name, local_dir)

        file_name = remote_dir + file_prefix + "_" + \
            env.host_string.replace(":", "_") + "_ethtool.log"

        run('touch %s' % file_name)
        interfaces = get_netint_cached(env.host_string, int_no=-1)
        for interface in interfaces:
            run('ethtool -k %s >> %s' % (interface, file_name))
        getfile(file_name, local_dir)
Пример #18
0
#!/usr/local/bin/python3
#-*- coding: utf-8 -*-
# Глава 13. Сценарии на стороне клиента.
# Передача файлов с помощью ftplib.
# Утилиты FTP get и put.
# Воспроизведение музыкальной темы Monty Python.
# Пример 13.6 (Лутц Т2 стр.135)
"""
# ---------------------------------------------------------------------------- #
Порядок использования: sousa.py. Загружает и проигрывает музыкальную
тему Monty Python. В текущем виде может не работать в вашей системе:
он требует, чтобы компьютер был подключен к Интернету, имелась
учетная запись на сервере FTP, и использует аудиофильтры в Unix и плеер
файлов .au в Windows. Настройте этот файл и файл playfile.py, как требуется.
# ---------------------------------------------------------------------------- #
"""

from getpass import getpass
from getfile import getfile
from Tom1.ch06.playfile import playfile

file = 'sousa.au'  # координаты файла по умолчанию
site = 'GMP'  # с музыкальной темой Monty Python
dir = '.'
user = ('combo', getpass('Pswd?'))

getfile(file, site, dir, user)  # загрузить айдиофайл по FTP
playfile(file)  # передать его аудиоплееру

# import os
# os.system('getone.py sousa.au')						# эквивалент командной строки
#!/usr/local/bin/python
################################################################
# A Python script to download and build Python's source code.
# Uses getfile.py, a utility module which encapsulates ftp step.
################################################################

import getfile

Version = '1.5'  # version to download
tarname = 'python%s.tar.gz' % Version  # remote/local file name

# fetch with utility
getfile.getfile(tarname, 'ftp.python.org', 'pub/python/src')

# rest is the same
execfile('buildPython.py')
Пример #20
0
def stop_tcp_logger(file_prefix='', remote_dir='', local_dir='.'):
    "Stop TCP logger (e.g. siftr on FreeBSD)"

    # get host type
    htype = get_type_cached(env.host_string)

    if htype == 'FreeBSD':
        run('sysctl net.inet.siftr.enabled=0')
        run('kldunload siftr')
        logfile = file_prefix + '_' + \
            env.host_string.replace(':', '_') + '_siftr.log'

    elif htype == 'Linux':
        # In fact, stop_tcp_logger is called just when Linux
        # and ttprobe are used (not with web10g)
        # but we check linux_tcp_logger type just in case
        # run('killall web100-logger')

        try:
            linux_tcp_logger = config.TPCONF_linux_tcp_logger
        except AttributeError:
            linux_tcp_logger = 'web10g'

        if linux_tcp_logger == 'ttprobe' or linux_tcp_logger == 'both':
            # flush ttprobe module buffer
            run('echo flush > /proc/net/ttprobe')
            time.sleep(0.5)
            run('echo finish > /proc/net/ttprobe')
            #run('pkill -f "cat /proc/net/ttprobe"')
            run('rmmod ttprobe')
            logfile = file_prefix + '_' + \
                env.host_string.replace(':', '_') + '_ttprobe.log'
        # complete other tasks and exit from this function because ttprobe has differnt bgproce
        # name
        if file_prefix != '' or remote_dir != '':
            file_name = logfile
        else:
            file_name = bgproc.get_proc_log(env.host_string, 'tcploggerprobe', '00')
        getfile(file_name, local_dir)
        bgproc.remove_proc(env.host_string, 'tcploggerprobe', '00')
        return

    elif htype == 'Darwin':
        pass

    elif htype == 'CYGWIN':
        run('killall win-estats-logger')
        logfile = file_prefix + '_' + \
            env.host_string.replace(':', '_') + '_web10g.log'

    if logfile == '':
        if remote_dir != '':
            logfile = remote_dir + '/' + logfile

    if file_prefix != '' or remote_dir != '':
        file_name = logfile
    else:
        file_name = bgproc.get_proc_log(env.host_string, 'tcplogger', '00')

    # add a small delay to allow logger to write data to disk completely
    time.sleep(0.5)

    # commented out: I think it may be confusing if the stats not match etc.
    # if htype == 'FreeBSD':
    # filter out control traffic from siftr log but
    # stats and flow list in last line of log is left unchanged
    #host = env.host_string.split(':')[0]
    #tmp_file = local('mktemp "tmp.XXXXXXXXXX"', capture=True)
    # run('cat %s | grep -v ",%s," > %s && mv %s %s' % \
    #    (file_name, host, tmp_file, tmp_file, file_name))

    getfile(file_name, local_dir)
    bgproc.remove_proc(env.host_string, 'tcplogger', '00')
Пример #21
0
#!/usr/local/bin/python
################################################################
# A Python script to download and build Python's source code.
# Uses getfile.py, a utility module which encapsulates ftp step.
################################################################

import getfile
version = '2.4'  # version to download
tarname = 'Python-%s.tgz' % version  # remote/local file name

# fetch with utility
getfile.getfile(tarname, 'ftp.python.org', 'pub/python/' + version)

# rest is the same
execfile('buildPython.py')
Пример #22
0
        plt.plot(bias, Jabs)

        #plt.plot(Vrev,Jcorr)
        #plt.plot(bias,Jsh)
        plt.title('ETL = C60 / LiF / Al', size=26)
        #plt.text(-2.8,1e-7,f'Jd @ -2V = {abs(J[bias.index(-2)]):.2e} A/cm²\nRsh = {Rsh:.2e} Ω/cm²\nRs = {Rs:.2e} Ω/cm²\n',fontsize=15,style='normal')
    mat = np.array(lJd)
    plt.text(
        -2.8,
        1e-5,
        f'Jd @ -2V= {np.mean(mat):.2e} ± {np.std(mat):.2e}({min(lJd):.2e}) A/cm²',
        fontsize=25,
        style='normal')
    print(
        f'Jd @ -2V= {np.mean(mat):.2e} ± {np.std(mat):.2e}({min(lJd):.2e}) A/cm²'
    )


#输入文件夹及关键字,路径'\'用'/'代替
plt.figure(figsize=(16, 9))  #设置图片大小
filetxt_list = getfile('jv/ps-20200627', '.txt', 's2', '')
plotjv(filetxt_list)
'''filetxt_list=getfile('jv/ps-20200707','.txt','s3','')
plotjv(filetxt_list)'''
'''getfile('jv/ps-20200701','s2','0.01')
plotjv(filetxt_list)
getfile('jv/ps-20200701','s3','0.01')
plotjv(filetxt_list)
filetxt_list=[]'''

plt.show()
Пример #23
0
#!/usr/local/bin/python
"""
A Python script to download and play a media file by FTP.
Uses getfile.py. 
"""
# change sys path when getfile not in directory
import getfile
from getpass import getpass

filename = "monkeys.jpg"
getfile.getfile(file=filename, 
		site="ftp.rmi.ent",
		dir=".",
		user=("lutz", getpass("Pswd?")),
		refetch=True)
 
if input("Open file?") in ["Y", "y"]:
	from PP4E.System.Media.playfile import playfile
	playfile(filename)

 def do_transfer(self, filename, servername, remotedir, userinfo):
     getfile.getfile(filename, servername, remotedir, userinfo, 0, 1)
Пример #25
0
#!/usr/local/bin/python
"""
Сценарий на языке Python для загрузки медиафайла по FTP и его проигрывания.
Использует getfile.py, вспомогательный модуль, инкапсулирующий
этап загрузки по FTP.
"""
import getfile
from getpass import getpass

filename = 'monkeys.jpg'
# получить файл с помощью вспомогательного модуля
getfile.getfile(file=filename,
                site='ftp.rmi.net',
                dir='.',
                user=('lutz', getpass('Pswd?')),
                refetch=True)
# остальная часть сценария осталась без изменений
if input('Open file?') in ['Y', 'y']:
    from PP.System.Media.playfile import playfile
    playfile(filename)
Пример #26
0
#!/usr/bin/python
"""
A Python script to download and play a media file by FTP.
Uses getfile.py, a utility module which encapsulates FTP step.
"""

import getfile
from getpass import getpass
filename = 'a.txt'

# fetch with utility
getfile.getfile(file=filename,
		site='211.147.216.11',
		dir='.',
		user=('*****@*****.**', getpass('Pswd?')),
		refetch=True)

# rest is the same
if input('Open file?') in ['Y', 'y']:
	from pp4e.System.Media.playfile 
	playfile(filename)
Пример #27
0
 def do_transfer(self, filename, servername, remotedir, userinfo):
     getfile.getfile(
         filename, servername, remotedir, userinfo, verbose=False, refetch=True)
#!/usr/local/bin/python
################################################################
# A Python script to download and build Python's source code.
# Uses getfile.py, a utility module which encapsulates ftp step.
################################################################

import getfile
Version = '1.5'                         # version to download
tarname = 'python%s.tar.gz' % Version   # remote/local file name

# fetch with utility 
getfile.getfile(tarname, 'ftp.python.org', 'pub/python/src')

# rest is the same
execfile('buildPython.py')
Пример #29
0
def log_sysdata(file_prefix='', remote_dir='', local_dir='.'):
    "Log various information for each system"

    if remote_dir != '' and remote_dir[-1] != '/':
        remote_dir += '/'

    # get host type
    htype = get_type_cached(env.host_string)

    file_name = remote_dir + file_prefix + "_" + \
        env.host_string.replace(":", "_") + "_uname.log"
    run('uname -a > %s' % file_name, pty=False)
    getfile(file_name, local_dir)

    file_name = remote_dir + file_prefix + "_" + \
        env.host_string.replace(":", "_") + "_netstat.log"
    run('netstat -nr > %s' % file_name, pty=False)
    getfile(file_name, local_dir)

    file_name = remote_dir + file_prefix + "_" + \
        env.host_string.replace(":", "_") + "_sysctl.log"
    if htype == 'FreeBSD' or htype == 'Linux' or htype == 'Darwin':
        run('sysctl -a > %s' % file_name)
    else:
        run('echo "netsh int show int" > %s' % file_name, pty=False)
        run('netsh int show int >> %s' % file_name, pty=False)
        run('echo "netsh int tcp show global" >> %s' % file_name, pty=False)
        run('netsh int tcp show global >> %s' % file_name, pty=False)
        run('echo "netsh int tcp show heuristics" >> %s' %
            file_name, pty=False)
        run('netsh int tcp show heuristics >> %s' % file_name, pty=False)
        run('echo "netsh int tcp show security" >> %s' % file_name, pty=False)
        run('netsh int tcp show security >> %s' % file_name, pty=False)
        run('echo "netsh int tcp show chimneystats" >> %s' %
            file_name, pty=False)
        run('netsh int tcp show chimneystats >> %s' % file_name, pty=False)
        run('echo "netsh int ip show offload" >> %s' % file_name, pty=False)
        run('netsh int ip show offload >> %s' % file_name, pty=False)
        run('echo "netsh int ip show global" >> %s' % file_name, pty=False)
        run('netsh int ip show global >> %s' % file_name, pty=False)

    getfile(file_name, local_dir)

    file_name = remote_dir + file_prefix + "_" + \
        env.host_string.replace(":", "_") + "_ifconfig.log"
    if htype == 'FreeBSD' or htype == 'Linux' or htype == 'Darwin':
        run('ifconfig -a > %s' % file_name)
    else:
        run('ipconfig > %s' % file_name, pty=False)
        # log interface speeds
        run('echo "wmic NIC where NetEnabled=true get Name, Speed" >> %s' % file_name, pty=False)
        run('wmic NIC where NetEnabled=true get Name, Speed >> %s' % file_name, pty=False)

    getfile(file_name, local_dir)

    file_name = remote_dir + file_prefix + "_" + \
        env.host_string.replace(":", "_") + "_procs.log"
    if htype == 'FreeBSD' or htype == 'Linux':
        run('ps -axu > %s' % file_name)
    elif htype == 'Darwin':
        run('ps -axu root > %s' % file_name)
    else:
        run('ps -alW > %s' % file_name, pty=False)

    getfile(file_name, local_dir)

    file_name = remote_dir + file_prefix + "_" + \
        env.host_string.replace(":", "_") + "_ntp.log"
    if htype == 'FreeBSD' or htype == 'Linux' or htype == 'Darwin':
        run('ntpq -4p > %s' % file_name)
    else:
        with settings(warn_only=True):
            # if we have ntp installed then use ntpq, otherwise use w32tm
            ret = run('ls "/cygdrive/c/Program Files (x86)/NTP/bin/ntpq"')
            if ret.return_code == 0:
                run('"/cygdrive/c/Program Files (x86)/NTP/bin/ntpq" -4p > %s' % 
                    file_name, pty=False)
            else:
                run('w32tm /query /status > %s' % file_name, pty=False)

    getfile(file_name, local_dir)

    # log tcp module parameters (Linux only)
    if htype == 'Linux':
        file_name = remote_dir + file_prefix + "_" + \
            env.host_string.replace(":", "_") + "_tcpmod.log"
        run("find /sys/module/tcp* -type f -exec grep -sH '' '{}' \; | "
            "grep -v Binary > %s" % file_name)
        getfile(file_name, local_dir)

        file_name = remote_dir + file_prefix + "_" + \
            env.host_string.replace(":", "_") + "_ethtool.log"

        run('touch %s' % file_name)
        interfaces = get_netint_cached(env.host_string, int_no=-1)
        for interface in interfaces:
            run('ethtool -k %s >> %s' % (interface, file_name))
        getfile(file_name, local_dir)
Пример #30
0
from hsize import hsize
from speedometter import SpeedOMetter
import numpy as np
from time import time

if __name__ == "__main__":
    start_time = time()
    times = []
    speeds = []
    try:
        url = 'http://192.168.1.254/gen/200M'
        # url = 'http://freebox/gen/200M'
        # url = 'http://test-debit.free.fr/image.iso'
        monitor = SpeedOMetter()
        for current, total in getfile(url,
                                      '/dev/null',
                                      chunksize=150000,
                                      headers={'Bytes-Range': '0-10000'}):
            speed = monitor.update(current)
            speeds.append(speed / (1024**2))
            times.append(time() - start_time)
            print(hsize(current), hsize(speed))
    except KeyboardInterrupt:
        pass
    plt.plot(times, speeds)
    plt.title('Freebox speed test')
    plt.xlabel = 'Time'
    plt.ylabel = 'Speed'
    plt.axhline(np.mean(speeds, 0), color='red', linestyle='--')
    plt.show()
Пример #31
0
#!/usr/local/bin/python3
#-*- coding: utf-8 -*-
# Глава 13. Сценарии на стороне клиента.
# Передача файлов с помощью ftplib.
# Утилиты FTP get и put.
# Пример 13.3 (Лутц Т2 стр.128)
"""
# ---------------------------------------------------------------------------- #
Сценарий на языке Python для загрузки медиафайла по FTP и его проигрывания.
Использует getfile.py, вспомогательный модуль, инкапсулирующий
этап загрузки по FTP.
# ---------------------------------------------------------------------------- #
"""

import getfile as getfile
from getpass import getpass

filename = 'spain08.jpg'

# получить файл с помощью вспомогательного модуля
getfile.getfile(file=filename,
				site='GMP',
				dir='.',
				user=('combo', getpass('Pswd?')),
				refetch=True)

# остальная часть сценария осталась без изменений
if input('Open file?') in ['Y', 'y']:
	from Tom1.ch06.playfile import playfile
	playfile(filename)