Пример #1
0
def getTandI_thread(myQueue,
                    torrentsPath,
                    enable_proxy=False,
                    proxy_string={
                        "http": "127.0.0.1:8787",
                        "https": "127.0.0.1:8787",
                        "socks": "127.0.0.1:1080"
                    }):
    "获取torrent的相关图片"
    proxies = {}
    timeout = 15
    picFilename = ''

    while True:
        try:
            tp = myQueue.get_nowait()
            j = myQueue.qsize()
        except Exception as e:
            break

    ##    n = 0
    ##    for tp in linksList:
        btsList = []
        imgsList = []
        ##    n=n+1
        print(tp['link'])
        tResDict = gettorrentlink3.get_torrentlink(myreq_url=str(tp['link']),
                                                   enable_proxy=enable_proxy,
                                                   proxy_string=proxy_string)
        for imgLink in tResDict['imgsList']:
            #outfilename =imgLink[imgLink.rfind('/')+1:len(imgLink)]
            outfilename = imgLink[imgLink.rfind('/') + 1:]
            a = {
                'link': imgLink,
                'ofile': outfilename,
                'oDir': str(torrentsPath + r'/' + tResDict['title'])
            }
            imgsList.append(a)
        if tResDict['btCode'] != 'notExist':
            b = {
                'link': tResDict['btCode'],
                'ofile': str(tResDict['title']) + '.torrent',
                'oDir': str(torrentsPath + r'/' + tResDict['title'])
            }
            btsList.append(b)

        if len(btsList) > 0:
            getFiles(fileList=btsList, m='p')
        if len(imgsList) > 0:
            getFiles(fileList=imgsList, m='g')
def clicked():
	directories.extend(getFiles.getFiles(txt.get()))
	directoryWindow = Toplevel(window)
	buttons = []
	variables = []
	j = 0
	def selectAll():
		for button in buttons:
			button.toggle()
	titleLabel = Label(directoryWindow, text="Select the scaffolding you want visualized")
	titleLabel.grid(row=0,column=((len(directories)%12)/2))
	selectAll = Button(directoryWindow, text="Select All", command=selectAll)
	selectAll.grid(row=1, column=((len(directories)%12)/2))
	for i in directories:
		variables.append(IntVar())
		dirNumber = int(i[9:])
		check = Checkbutton(directoryWindow, text=i, variable = variables[j], onvalue = 1, offvalue = 0)
		buttons.append(check)
		buttons[j].grid(row = dirNumber%12 + 2, column = dirNumber / 12)
		j += 1
	def done():
		k = 0
		paths = []
		for button in buttons:
			if variables[k].get():
				if (txt.get())[-1:] == '\\':
					paths.append(txt.get() + button['text'])
				else:
					paths.append(txt.get() + "\\" + button['text'])
			k += 1
		paths.sort(key = lambda x: x[-7:].split('-')[1])
		graph.createVisualization(paths)
	goButton = Button(directoryWindow, text="Go", command=done)
	goButton.grid(row=15,column=((len(directories)%12)/2))
Пример #3
0
    def __init__(self, dirname):
        # Initialize markov chain models 

        self.dirname = dirname

        # For the case where the directory name is a folder.
        if not isfile(self.dirname):
            fileList = getFiles(self.dirname)

            for fileName in fileList:
                with open(join(self.dirname, fileName)) as f:
                    text = f.read()

                text_model = markovify.Text(text)
                self.modelList.append(text_model)

            self.model_combo = markovify.combine(self.modelList)

        # Else, assume it's a single valid.txt file. 
        else:
            with open(self.dirname) as f:
                text = f.read()

            self.model_combo = markovify.Text(text)
Пример #4
0
import heppy.framework.config as cfg

from getFiles import getFiles 

gun_piplus = cfg.Component(
    'gun_piplus',
    files = getFiles("/SinglePiPlus_P-1to2000_Expo_13TeV_ExpoRandomPGun/RunIISpring15DR74-AsymptNoPUReco_MCRUN2_74_V9A-v1/GEN-SIM-RECO", user='******'),
) 
Пример #5
0
import heppy.framework.config as cfg

from getFiles import getFiles 

ee_qq = cfg.Component(
    'ee_qq',
    files = getFiles("/ee_qq/745_v1/RECOSIM", cache=True),
) 


samples = [
    ee_qq
]

if __name__ == '__main__':

    import pprint 
    for g in samples:
        print g
Пример #6
0
import heppy.framework.config as cfg

from getFiles import getFiles 

qcd = cfg.Component(
    'qcd',
    files = getFiles(
        "/QCD_Pt-120to170_MuEnrichedPt5_TuneCUETP8M1_13TeV_pythia8/RunIISpring15DR74-AsymptNoPUReco_MCRUN2_74_V9A-v1/GEN-SIM-RECO", 
        user='******', cache=True),
) 

qcd_em = cfg.Component(
    'qcd_em',
    files = getFiles(
        "/QCD_Pt-15to20_EMEnriched_TuneCUETP8M1_13TeV_pythia8/RunIISpring15DR74-AsymptNoPUReco_MCRUN2_74_V9A-v1/GEN-SIM-RECO", 
        user='******', cache=True),
) 


samples = [
    qcd
]

if __name__ == '__main__':

    import pprint 
    for g in samples:
        print g
Пример #7
0
import heppy.framework.config as cfg

from getFiles import getFiles 

gun_211_0_20 = cfg.Component(
    'gun_211_0_20',
    files = getFiles("/Gun_221_0_20_ptflat/743_v1/AODSIM", cache=True),
) 

gun_211_0_10 = cfg.Component(
    'gun_211_0_10',
    files = getFiles("/Gun_211_0_10_ptflat/743_v1/AODSIM"),
) 

gun_211_MatEff_0_20 = cfg.Component(
    'gun_211_MatEff_0_20',
    files = getFiles("/Gun_221_MatEff_0_20_ptflat/743_v1/AODSIM", cache=True),
) 

gun_22_0_50 = cfg.Component(
    'gun_22_0_50',
    files = getFiles("/Gun_22_0_50/743_v2/RECOSIM"),
) 

gun_22_0_50_eta3 = cfg.Component(
    'gun_22_0_50_eta3',
    files = getFiles("/Gun_22_0_50_eta3/743_v2/AODSIM"),
) 

gun_130_0_50 = cfg.Component(
    'gun_130_0_50',
Пример #8
0
import heppy.framework.config as cfg

from getFiles import getFiles

qcd = cfg.Component(
    'qcd',
    files=getFiles(
        "/QCD_Pt-120to170_MuEnrichedPt5_TuneCUETP8M1_13TeV_pythia8/RunIISpring15DR74-AsymptNoPUReco_MCRUN2_74_V9A-v1/GEN-SIM-RECO",
        user='******',
        cache=True),
)

qcd_em = cfg.Component(
    'qcd_em',
    files=getFiles(
        "/QCD_Pt-15to20_EMEnriched_TuneCUETP8M1_13TeV_pythia8/RunIISpring15DR74-AsymptNoPUReco_MCRUN2_74_V9A-v1/GEN-SIM-RECO",
        user='******',
        cache=True),
)

samples = [qcd]

if __name__ == '__main__':

    import pprint
    for g in samples:
        print g
Пример #9
0
import heppy.framework.config as cfg

from getFiles import getFiles

wwh = cfg.Component(
    'wwh',
    files=getFiles("/WWH/HZHA_100k_v1/GEN"),
)

hz = cfg.Component(
    'hz',
    files=getFiles("/HZ/HZHA_100k_v1/GEN"),
)

hz_cms = cfg.Component(
    'hz_cms',
    files=getFiles("/HZ/HZHA_100k_fastsim_v1/AODSIM"),
)

samples = [wwh, hz]

samples_cms = [hz_cms]

if __name__ == '__main__':

    import pprint
    for g in samples:
        print g
Пример #10
0
import heppy.framework.config as cfg

from getFiles import getFiles

gun_piplus = cfg.Component(
    'gun_piplus',
    files=getFiles(
        "/SinglePiPlus_P-1to2000_Expo_13TeV_ExpoRandomPGun/RunIISpring15DR74-AsymptNoPUReco_MCRUN2_74_V9A-v1/GEN-SIM-RECO",
        user='******'),
)
Пример #11
0
import heppy.framework.config as cfg

from getFiles import getFiles

gun_211_MatEff_10_50 = cfg.Component(
    'gun_211_Mateff_10_50',
    files=getFiles("/Gun_211_MatEff_10_50/743_v1/RECOSIM"),
)

samples = [
    gun_211_MatEff_10_50,
]

if __name__ == '__main__':

    import pprint
    for g in samples:
        print g
Пример #12
0
#from contours import contours_segm

from getRNU import getRNU
from getFiles import getFiles
from skimage.filters import sobel
import matplotlib.pyplot as plt
from skimage import morphology
from skimage.morphology import watershed

from skimage.color import label2rgb
from scipy import ndimage as ndi

from skimage.measure import label

lstFilesDCM = []
lstFilesDCM = getFiles()

for fileDCM in lstFilesDCM:
    ds = pydicom.read_file(fileDCM)
    image = ds.pixel_array
    #couting number of gray levels
    greylevels = np.unique(image)
    levels = np.unique(greylevels).shape[0]
    #calcula mapa de elevação
    elevation_map = sobel(image / int(levels))
    #montagem das mascaras
    markers = np.zeros_like(image / int(levels))
    markers[image < 600] = 1
    markers[image > 2800] = 0

    fig, ax = plt.subplots(figsize=(4, 3))
Пример #13
0
import heppy.framework.config as cfg

from getFiles import getFiles 


wwh = cfg.Component(
    'wwh',
    files = getFiles("/WWH/HZHA_100k_v1/GEN"),
) 

hz = cfg.Component(
    'hz',
    files = getFiles("/HZ/HZHA_100k_v1/GEN"),
) 

hz_cms =  cfg.Component(
    'hz_cms',
    files = getFiles("/HZ/HZHA_100k_fastsim_v1/AODSIM"),
) 

samples = [
    wwh,
    hz
]

samples_cms = [
    hz_cms
]

if __name__ == '__main__':
Пример #14
0
import heppy.framework.config as cfg

from getFiles import getFiles

ee_qq = cfg.Component("ee_qq", files=getFiles("/ee_qq/745_v1/RECOSIM", cache=True))


samples = [ee_qq]

if __name__ == "__main__":

    import pprint

    for g in samples:
        print g
Пример #15
0
def main():
    reload(sys)
    #print u'系统默认编码:',sys.getdefaultencoding() #获取系统默认编码
    #sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='gb18030') #改变标准输出的默认编码

    #sys.setdefaultencoding("utf-8")
    #print u'现在编码:',sys.getdefaultencoding()

    init(autoreset=True)

    #调用时使用gettorrent.get_torrent()
    #或者 from getpagelink import *
    #from gettorrentlink import *
    #from gettorrent import *
    #调用时直接使用 get_torrent

    torrentsPath = 'torrents'
    if not os.path.exists(torrentsPath):
        os.makedirs(torrentsPath)

    enable_proxy = False
    if enable_proxy:
        print('proxy enabled\n\n')
    else:
        print('proxy disabled\n\n')
    '''
    if enable_proxy:
        print Fore.GREEN + 'proxy enabled\n\n'
    else:
        print Fore.GREEN + 'proxy disabled\n\n'
    '''
    proxy_string = {
        "http": "127.0.0.1:8787",
        "https": "127.0.0.1:8787",
        "socks": "127.0.0.1:1080"
    }
    user_agent = 'Mozilla/5.0'

    if len(sys.argv) > 1:
        firstpage_number = int(sys.argv[1])
        total_pages = int(sys.argv[2])
    else:
        firstpage_number = 1
        total_pages = 1

    page_host = u'bt.aisex.com'
    pagelink_pre = u'https://' + page_host + u'/bt/thread.php?fid=16&page='
    ##    link_dict = {} #link_dict:  {pagenumber:{fulllink:torrentfilename}}
    ##    link_count = 0
    ##    torrentItemList = []
    linksList = getpagelink3.getLinksLists(indexPageS=firstpage_number,
                                           indexPageC=total_pages)
    ##    link_count = link_count + len(link_dict[mypage_number])
    print('Total links:', len(linksList))
    '''
    print Fore.YELLOW + 'link_dict length is: '+str(len(link_dict)) + '\n'
    print Fore.CYAN + 'Total links: ', link_count, '\n'
    '''

    #顺序下载方式-------start-------------
    ##    btsList = []
    ##    imgsList = []
    n = 0
    for tp in linksList:
        btsList = []
        imgsList = []
        n = n + 1
        print(n, tp['link'])
        tResDict = gettorrentlink3.get_torrentlink(myreq_url=str(tp['link']),
                                                   enable_proxy=enable_proxy,
                                                   proxy_string=proxy_string)
        for imgLink in tResDict['imgsList']:
            outfilename = imgLink[imgLink.rfind('/') + 1:len(imgLink)]
            a = {
                'link': imgLink,
                'ofile': outfilename,
                'oDir': str(torrentsPath + r'/' + tResDict['title'])
            }
            imgsList.append(a)
        if tResDict['btCode'] != 'notExist':
            b = {
                'link': tResDict['btCode'],
                'ofile': str(tResDict['title']) + '.torrent',
                'oDir': str(torrentsPath + r'/' + tResDict['title'])
            }
            btsList.append(b)

        if len(imgsList) > 0:
            getFiles(fileList=imgsList, m='g')
        if len(btsList) > 0:
            print(len(btsList))
            getFiles(fileList=btsList, m='p')


##    for item in imgsList:
##        print(item)
##    print()
##    for item in btsList:
##        print(item)
##    print()

##    if len(imgsList) >0:
##        getFiles(fileList=imgsList,m='g')
##    if len(btsList) >0:
##        getFiles(fileList=btsList,m='p')
#顺序下载方式-------End-------------

##    n = 0
##    link_nu = 1
##    for btItem in btsList:
##        print('page',link_nu)
##        for link,lTitle in link_dict[link_nu].items():
##            title = ''
##            imglinklist = []
##
##            n = n+1
##            print(Fore.GREEN + Style.BRIGHT + str(n),'page:',str(link))
##            #print(Fore.GREEN + Style.BRIGHT + str(n),'page:',link)
##            #print u'name 的编码形式: ',name.__class__ #获取name的编码形式
##            print(Fore.YELLOW + Style.BRIGHT + '     Title: ' + '\"' + lTitle + '\"')
##
##            '''
##            #去除文件名中的问号
##            symbol_remove = re.compile(r'["?"]')
##            lTitle = symbol_remove.sub('',lTitle)
##            symbol_remove = re.compile("['\u2764','\u3099','\u266a']")
##            lTitle = symbol_remove.sub('',lTitle)
##            '''
##            outfile_name = str(btItem['title'] + '.torrent')
##            outdir = str(torrentsPath + r'/' + btItem['title'])
##            if not os.path.exists(outdir):
##                os.makedirs(outdir)
##            outfile_full_path = str(outdir + r'/' + outfile_name)
##
##            if os.path.exists(outfile_full_path) and os.path.isfile(outfile_full_path) and os.access(outfile_full_path,os.R_OK):
##                print(Fore.RED + Style.BRIGHT + 'this torrent file already exist, skip.\n')
##            else:
##                #获取torrent代码
##                torrent_code,title,imglinklist = gettorrentlink3.get_torrentlink(myreq_url = link, enable_proxy = enable_proxy, proxy_string = proxy_string)
##                print('     CODE:', torrent_code)
##                print(title,imglinklist)
##                print('total ',len(imglinklist),' pics.')
##
####                torrent_item = {'tCode':torrent_code,'tTitle':title,'imgLinkList':imglinklist}
##                torrentItemList.append(torrent_item)
##
####                fileList = []
####                for imgLink in imglinklist:
####                    outdir = str(torrentsPath + r'/' + title)
####                    ifilename = imgLink[imgLink.rfind('/')+1:len(imgLink)]
####                    fileList.append({link:imgLink,ofile:ifilename})
##
##
##                #保存图片
##                getImgs(imglinklist,outdir)
####                if len(imglinklist) > 0:
####                    for imglink in imglinklist:
####                        picname,imgContent = getImg(imgLink = imglink)
####                        if len(imgContent) > 0:
####                            picFullpath = (outdir + r'/' + picname)
####                            ofile = open(picFullpath,'wb')
####                            ofile.write(imgContent)
####                            ofile.close()
##
##
##                #获取torrent内容
##                if torrent_code != 'notExist':
##                    torrent_content = gettorrent3.get_torrent(torrent_name_code = torrent_code, enable_proxy = enable_proxy, proxy_string = proxy_string)
##                    if b'<html>' not in torrent_content:
##                        #解码torrent
##                        try:
##                            btinfo = bencode.bdecode(torrent_content)
##                        except Exception as detail:
##                            print(Fore.RED + Style.BRIGHT + "     ERROR4: ",detail)
##                            print()
##                            continue
##                        #print '     decode torrent finished'
##
##
##                        '''
##                        info_list = []
##                        for i in btinfo:
##                            info_list.append(i)
##                            print(i)
##
##                        print("bt announce(tracker服务器列表):",btinfo[b'announce'].decode())
##                        print("bt announce-list(备用tracker列表):",btinfo[b'announce-list'].decode())
##                        lin_list=[]
##                        for udp_list in btinfo[b'announce-list']:
##                            for lin in udp_list:
##                                lin_list.append(lin.decode())
##                                print(lin.decode())
##                        print("bt comment:",btinfo[b'comment'].decode())
##                        print("bt creator:",btinfo[b'created by'].decode())
##                        print("bt 编码方式encoding:",btinfo[b'encoding'].decode())
##                        print("bt info:",btinfo[b'info'].decode())
##                        for k in btinfo[b'info'].keys():
##                            value = btinfo[b'info'][k]
##                            if k == b'files':
##                                print("total %d files"%len(value))
##                                for v_list_dic in value:
##                                    print(v_list_dic)
##                                    for files_k,files_v in v_list_dic.items():
##                                        print(files_k,files_v)
##                            elif k == b'name':
##                                print("file name:",value.decode())
##                            elif k == b'md5sum':
##                                print("md5:",value)
##                            elif k == b'length':
##                                print("file size:",value)
##                            elif k == b'path':
##                                print("file path name:",value)
##                            elif k == b'piece length':
##                                print("每个块的大小:",value)
##                            elif k == b'pieces':
##                                print("每个块的20个字节的SHA1 Hash的值(二进制格式):",str(value))
##                        print("nodes的数据类型:",type(btinfo[b'nodes']))
##                        print(btinfo[b'nodes'])
##                        '''
##
##
##                        info = btinfo[b'info']
##                        btlist = {}
##                        fsize = 0
##                        for bfile in info[b'files']:
##                            if len(bfile[b'path']) > 1:
##                                fname0 = str(bfile[b'path'][0])+'/'+str(bfile[b'path'][1])
##                            else:
##                                fname0 = bfile[b'path'][0]
##                            btlist[bfile[b'path'][0]] = {'path':fname0,'size':bfile[b'length']} #生成新字典{path:{'path':path,'size':size}}
##
##                            if bfile[b'length'] > fsize:
##                                fname = fname0
##                                fsize = bfile[b'length']
##
##                        '''
##                        fsize = 0
##                        for key,val in btlist.items():
##                            if val['size'] > fsize:
##                                fsize = val['size']
##                                temppath = val['path']
##                                '''
##                        print('     files:',len(btlist))
##                        try:
##                            print('     the MAX file in the torrent is: ', fname.decode('utf-8'), ' size:', str(fsize))
##                        except Exception as detail:
##                            print('     Error5: ',detail)
##
##                        #输出torrent文件
##                        print('    save file to:', outfile_full_path)
##                        print()
##                        outFile = open(outfile_full_path,'wb')
##                        outFile.write(torrent_content)
##                        outFile.close()
##                        #time.sleep(1)
##                    else:
##                        print('torrent not exist!')
##                else:
##                    print('torrent_code not exist!')
##
##    print(torrentItemList)
    print('over')
Пример #16
0
import heppy.framework.config as cfg

from getFiles import getFiles

gun_211_0_20 = cfg.Component(
    'gun_211_0_20',
    files=getFiles("/Gun_221_0_20_ptflat/743_v1/AODSIM", cache=True),
)

gun_211_0_10 = cfg.Component(
    'gun_211_0_10',
    files=getFiles("/Gun_211_0_10_ptflat/743_v1/AODSIM"),
)

gun_211_MatEff_0_20 = cfg.Component(
    'gun_211_MatEff_0_20',
    files=getFiles("/Gun_221_MatEff_0_20_ptflat/743_v1/AODSIM", cache=True),
)

gun_22_0_50 = cfg.Component(
    'gun_22_0_50',
    files=getFiles("/Gun_22_0_50/743_v2/RECOSIM"),
)

gun_22_0_50_eta3 = cfg.Component(
    'gun_22_0_50_eta3',
    files=getFiles("/Gun_22_0_50_eta3/743_v2/AODSIM"),
)

gun_130_0_50 = cfg.Component(
    'gun_130_0_50',
Пример #17
0
import heppy.framework.config as cfg

from getFiles import getFiles 

gun_211_MatEff_10_50 = cfg.Component(
    'gun_211_Mateff_10_50',
    files = getFiles("/Gun_211_MatEff_10_50/743_v1/RECOSIM"),
) 



samples = [
    gun_211_MatEff_10_50,
]

if __name__ == '__main__':

    import pprint 
    for g in samples:
        print g