• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python urllib.urlopen函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中urllib.urlopen函数的典型用法代码示例。如果您正苦于以下问题:Python urlopen函数的具体用法?Python urlopen怎么用?Python urlopen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了urlopen函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: getRss

def getRss():
	codert = urllib.urlopen("http://actualidad.rt.com/feeds/all.rss?rss=1")
	codetn = urllib.urlopen("http://www.tn.com.ar/rss.xml")
	codeinfobae = urllib.urlopen("http://cdn01.ib.infobae.com/adjuntos/162/rss/Infobae.xml")
	#codetelam = urllib.urlopen("http://www.telam.com.ar/rss2/ultimasnoticas.xml")

	jsonrt = {"rss" : base64.b64encode(codert.read())}
	filert = open("../servicios/rt/serv.json", 'w')
	filert.write(json.dumps(jsonrt))
	filert.close()

	jsontn = {"rss" : base64.b64encode(codetn.read())}
	filetn = open("../servicios/tn/serv.json", 'w')
	filetn.write(json.dumps(jsontn))
	filetn.close()

	jsoninfobae = {"rss" : base64.b64encode(codeinfobae.read())}
	fileinfobae = open("../servicios/infobae/serv.json", 'w')
	fileinfobae.write(json.dumps(jsoninfobae))
	filert.close()

	'''filetelam = open("../servicios/telam/rss.xml", 'w')
	filetelam.write(codetelam.read())
	filetelam.close()'''

	print getTime(),"[RSS] RSS's actualizados"

	threading.Timer(300.0, getRss).start()
开发者ID:asp95,项目名称:hoyllego,代码行数:28,代码来源:backend.py


示例2: wait_on_app

def wait_on_app(port):
  """ Waits for the application hosted on this machine, on the given port,
      to respond to HTTP requests.

  Args:
    port: Port where app is hosted on the local machine
  Returns:
    True on success, False otherwise
  """
  backoff = INITIAL_BACKOFF_TIME
  retries = MAX_FETCH_ATTEMPTS
  private_ip = appscale_info.get_private_ip()

  url = "http://" + private_ip + ":" + str(port) + FETCH_PATH
  while retries > 0:
    try:
      urllib.urlopen(url)
      return True
    except IOError:
      retries -= 1

    logging.warning("Application was not up at %s, retrying in %d seconds"%\
                   (url, backoff))
    time.sleep(backoff)
    backoff *= 2

  logging.error("Application did not come up on %s after %d attemps"%\
                (url, MAX_FETCH_ATTEMPTS))
  return False
开发者ID:camtaylor,项目名称:appscale,代码行数:29,代码来源:app_manager_server.py


示例3: find_proxy

def find_proxy( url, timeout, testing_url):

	try:
		response = urllib.urlopen( url )
	except:
		if Debug: print "Request to get proxy failed."
		return (False, False)

	result=response.getcode()

	content = response.read()

	data = json.loads( content )

	if Debug: print data['curl']

	start_time = time.time()

	try:
		response = urllib.urlopen(testing_url, proxies={'http':data['curl']})
	except:
		if Debug: print "Proxy test request failed."
		return (False, False)

	result=response.getcode()
	request_time = time.time() - start_time

	if result == 200: 
		if Debug: print "\n\nGot test url with %d in %f seconds" % (result, request_time)
		return (data['curl'], request_time)


	else:
		if Debug: print "Failed with %d" % result
		return (False, False)
开发者ID:Bschuster3434,项目名称:viral-launch-proxy-service,代码行数:35,代码来源:unknown.py


示例4: get

 def get(self, action=""):
     url = self.request.get("url")
     try: #bit.ly
         result = urllib.urlopen("http://api.bit.ly/v3/shorten?login=crowy&apiKey=R_57bab6c0fb01da4e1e0a5e22f73c3a4a&format=json&longUrl=%s" % urllib.quote(url)).read()
         json = simplejson.loads(result)
         if json['status_code'] == 200:
             self.response.out.write(json['data']['url'])
             return
         else:
             logging.warn(result)
     except:
         logging.warn("Unexpected error.")
     try: #goo.gl
         api_url = 'https://www.googleapis.com/urlshortener/v1/url?key=AIzaSyBRoz9ItBIQgHwWbZbmkF45dFiRKub2XzI&userip='+self.request.remote_addr
         post_data = simplejson.dumps({'longUrl':url})
         result = urlfetch.fetch(url=api_url,
                     payload=post_data,
                     method=urlfetch.POST,
                     headers={'Content-Type': 'application/json'})
         if result.status_code == 200:
             result = simplejson.loads(result.content)
             self.response.out.write(result['id'])
             return
         else:
             logging.warn(result.content)
     except:
         logging.warn("Unexpected error.")
     try:#tinyurl
         short_url = urllib.urlopen("http://tinyurl.com/api-create.php?url=%s" % urllib.quote(url))
         self.response.out.write(short_url.read())
         return
     except:
         logging.warn("Unexpected error.")
     self.error(400)
开发者ID:DJSimon,项目名称:crowy,代码行数:34,代码来源:main.py


示例5: run

    def run( self ):
        """Executes the body of the script."""
    
        logging.info("Log level set to INFO")
        logging.debug("Log Level set to DEBUG")
        
        jobNumber = self.jobNumber

        #print jobNumber
        #print jobNumber[:3]

        portalURL = self.server
        home = '/home/sbsuser/pacbio/raw/'
        splicehome = '/pacbio/raw'
        ext = self.opts.ext
        #print ext
        records = set()
            
        if ext == "ccs_reads.fastq":
            cmd = 'wget http://node1.1425mad.mssm.edu/pacbio/secondary/%s/%s/data/ccs_reads.fastq' % (jobNumber[:3],jobNumber)
            logging.info(cmd)
            os.system(cmd)
        elif ext == "cmp.h5":
            #logIn = urllib.urlopen('http://node1.1425mad.mssm.edu/pacbio/secondary/%s/%s/data/aligned_reads.cmp.h5' % (jobNumber[:3],jobNumber))
            cmd = 'wget http://node1.1425mad.mssm.edu/pacbio/secondary/%s/%s/data/aligned_reads.cmp.h5' % (jobNumber[:3],jobNumber)
            logging.info(cmd)
            os.system(cmd)
        elif ext == "bax.h5":

            logIn = urllib.urlopen('http://node1.1425mad.mssm.edu/pacbio/secondary/%s/%s/log/smrtpipe.log' % (jobNumber[:3],jobNumber))
            for line in logIn:
                if home in line:
                    ll = line.split(" ")
                    #print "starting a new set:"
                    #print ll
                    #print "raw: ", line
                    line = ll[-3]
                    #print "split: ", line
                    #print portalURL
                    #print line[line.find(splicehome):line.find("bax.h5")]
                    #print ext
                    if not "m" in line[line.find(splicehome):line.find("bax.h5")]:
                        continue

                    records.add(portalURL+line[line.find(splicehome):line.find("bax.h5")] + ext)
                    records.add(portalURL+line[line.find(splicehome):line.find("bax.h5")-2] + "bas.h5")
                    #print records
        else:
            print >>sys.stderr, "Not supported file type!"

        for address in records:
            logging.info(address)
            fileIn = urllib.urlopen(address)
            if self.opts.noprefix:
                fileout = open(address.split('/')[-1],'w')
            else:
                fileout = open(self.prefix+address.split('/')[-1],'w')
            fileout.write(fileIn.read())
            fileout.close()	
        return 0
开发者ID:alibashir,项目名称:pathogendb-pipeline,代码行数:60,代码来源:ccs_get.py


示例6: downloadPSSOPage

    def downloadPSSOPage(self):
        username = self.lineEdit.text()
        password = self.lineEdit_2.text()
        login_url = 'https://psso.fh-koeln.de/qisserver/rds?state=user&type=1&category=auth.login&startpage=portal.vm&breadCrumbSource=portal'
        params = urllib.urlencode({'asdf': username, 'fdsa': password, 'submit':'Login'}) # lol
        html_1 = urllib.urlopen(login_url, params).read()

        if not noten.checkLogin(html_1):
            self.showErrorPopup(u"Sind die Login Daten möglicherweise falsch?")
            return
        try:
            # Von hier an simulieren wir einen Crawler
            html_2 = urllib.urlopen(noten.getLinkByName(html_1, "Prüfungsverwaltung")).read()
            html_3 = urllib.urlopen(noten.getLinkByName(html_2, "Notenspiegel")).read()
            html_4 = urllib.urlopen(noten.getLinkByName(html_3, re.compile("Abschluss"))).read()
            html_5 = urllib.urlopen(noten.getLinkByGraphic(html_4, "/QIS/images//his_info3.gif")).read()
        except TypeError as e:
           self.showErrorPopup(u"Scheinbar haben sich die PSSO Seiten verändert… Sag' bitte Hugo bescheid, damit er das Programm reparieren kann!")
           return
        try:
            anz_noten, anz_credits, schnitt = noten.getInfos(html_5)
            name = noten.getStudentName(html_5)
            self.presentResults(anz_noten, anz_credits, schnitt, name)
        except noten.ParsingError as e:
            self.showErrorPopup(str(e))
开发者ID:hubertgrzeskowiak,项目名称:PSSOptimisation,代码行数:25,代码来源:qt_noten.py


示例7: parseresultpage

def parseresultpage(page, search, order, sort, regex):
    logger.info("    [+] Pulling results from page " + str(page))
    githubbase = "https://github.com/search?"
    githubsearchurl = {"o": order, "p": page, "q": search, "s": sort, "type": "Code", "ref": "searchresults"}
    searchurl = githubbase + str(urlencode(githubsearchurl))
    pagehtml = urlopen(searchurl).read()
    soup = BeautifulSoup(pagehtml, "html.parser")

    # Find GitHub div with code results
    results = soup.findAll("div", attrs={"class": "code-list-item"})

    # Pull url's from results and hit each of them
    soup1 = BeautifulSoup(str(results), "html.parser")
    for item in soup1.findAll("p", attrs={"class": "full-path"}):
        soup2 = BeautifulSoup(str(item), "html.parser")
        for link in soup2.findAll("a"):
            individualresult = "https://github.com" + str(link["href"])
            individualresultpage = urlopen(individualresult).read()
            soup3 = BeautifulSoup(str(individualresultpage), "html.parser")
            for rawlink in soup3.findAll("a", attrs={"id": "raw-url"}):
                rawurl = "https://github.com" + str(rawlink["href"])
                if args.custom_regex:
                    searchcode(rawurl, regex)
                else:
                    wpsearchcode(rawurl, regex)
开发者ID:jahrik,项目名称:GitHarvester,代码行数:25,代码来源:githarvester.py


示例8: main_loop

 def main_loop(self):
     while True:
         try:
             time.sleep(1)
             this_dir = os.listdir(os.getcwd())
             that_dir = eval(urllib.urlopen(self.url + "/list/" + self.username + "/" + self.password).read())
             if str(this_dir) != str(that_dir):
                 for this in this_dir:
                     if this not in self.files and this != sys.argv[0]:
                         with open(this, "rb") as md5file:
                             print "added", this
                             self.files[this] = hashlib.md5(md5file.read()).hexdigest()
                     if this not in that_dir and this != sys.argv[0]:
                         thread.start_new_thread(self.upload, (this,))
                 for that in that_dir:
                     if that not in this_dir:
                         thread.start_new_thread(self.download, (that,))
                 for file in self.files:
                     try:
                         with open(file, "rb") as check_file:
                             check = hashlib.md5(check_file.read()).hexdigest()
                             if check != self.files[file]:
                                 print file, "changed"
                                 urllib.urlopen(
                                     self.url + "/delete/" + self.username + "/" + self.password + "/" + file
                                 )
                                 self.files[file] = check
                                 thread.start_new_thread(self.upload, (file,))
                     except IOError:
                         pass
         except IOError:
             print "It seems as though your server is down, please check it."
             time.sleep(60)
开发者ID:kamwoods,项目名称:MatchBox,代码行数:33,代码来源:client.py


示例9: get_cur

    def get_cur(self):
        types = ('alpha','beta','pre','rc',None,'p')
        version = self.base[0]
        if self.opts.version is not None:
            version = self.opts.version

        type = self.base[1]
        if self.opts.type == 'tagged':
            type = 4
            self.opts.hash = None
        elif self.opts.type is not None:
            type = types.index(self.opts.type)

        if self.opts.branch:
            self.branch = self.opts.branch
        elif type < 4:
            self.branch = 'master'
        else:
            self.branch = 'fixes/{0}'.format('.'.join(version.split('.')[0:2]))

        if type != 4:
            if self.opts.hash is None:
                commit = json.load(urllib.urlopen("https://api.github.com/repos/mythtv/MythTV/commits/" + urllib.quote(self.branch, '')))
                self.opts.hash = commit['sha']
                if self.opts.date is None:
                    self.opts.date = process_date(commit['commit']['committer']['date']).strftime('%Y%m%d')
                print "Autoselecting hash: "+self.opts.hash
            elif self.opts.date is None:
                commit = json.load(urllib.urlopen("https://api.github.com/repos/mythtv/MythTV/commits/" + self.opts.hash))
                self.opts.date = process_date(commit['commit']['committer']['date']).strftime('%Y%m%d')

        self.cur = (version, type, self.opts.date)
        if self.opts.verbose: print 'New version set to: {0}-{1}'.format(self.name,self.get_version(self.cur))
开发者ID:toaster,项目名称:packaging,代码行数:33,代码来源:mythtv-buildebuild.py


示例10: update_urls

def update_urls():
    workers = itertools.cycle(models.get_workers())
    remote_urls = models.get_urls_to_check()
    for url in remote_urls:
        response = _make_request(workers.next(), url)
        for subscriber in url.subscribers:
            urllib.urlopen(subscriber.callback, data=response)
开发者ID:imankulov,项目名称:urlobserver,代码行数:7,代码来源:utils.py


示例11: __init__

  def __init__(self, versions):
    self.versions = versions

    resp = urllib.urlopen("https://issues.apache.org/jira/rest/api/2/field")
    data = json.loads(resp.read())

    self.fieldIdMap = {}
    for part in data:
      self.fieldIdMap[part['name']] = part['id']

    self.jiras = []
    at=0
    end=1
    count=100
    while (at < end):
      params = urllib.urlencode({'jql': "project in (HADOOP,HDFS,MAPREDUCE,YARN) and fixVersion in ('"+"' , '".join(versions)+"') and resolution = Fixed", 'startAt':at, 'maxResults':count})
      resp = urllib.urlopen("https://issues.apache.org/jira/rest/api/2/search?%s"%params)
      data = json.loads(resp.read())
      if (data.has_key('errorMessages')):
        raise Exception(data['errorMessages'])
      at = data['startAt'] + data['maxResults']
      end = data['total']
      self.jiras.extend(data['issues'])

    self.iter = self.jiras.__iter__()
开发者ID:3h-william,项目名称:hadoop2.0-research,代码行数:25,代码来源:relnotes.py


示例12: SendSms

    def SendSms(self,text="Default text message"):

        deltaT=datetime.now()-self.last_sms
        if  deltaT.seconds>self.min_period or self.sent==0:
            if self.settings.debug>0:
                logging.info("Debug SMS sent %s " %time.strftime("%I:%M:%S %p", time.localtime()))
                self.sent=1
                return 1
            else:
                self.last_sms=datetime.now()
                self.config={}
                self.config['username']=self.username
                self.config['password']=self.password
                #needs to be changed with international prefix what an hassle!
                self.config['to']=self.to
                self.config['from']=self.sender
                self.config['text']=text
                self.config['maxconcat']=self.MaxConCatMsgs
                query = urllib.urlencode(self.config)
                try:
                    if self.UseProxies>0 :
                        file = urllib.urlopen(self.url1+self.pushpage, query,proxies=self.proxies)
                    else:
                        file = urllib.urlopen(self.url1+self.pushpage, query,proxies=None)
                except IOError, (errno):
                    logging.error ("Error delivering online SMS %s " %errno) 
                    return 0
                self.sent=1
                self.output = file.read()
                file.close()
                logging.info("Message sent to %s from %s" % (self.to, self.sender)) 
                #return self.ParseRequest()
                return 1
开发者ID:Pepe74,项目名称:panstamp,代码行数:33,代码来源:messaging.py


示例13: _TreeStatusTestHelper

  def _TreeStatusTestHelper(self, tree_status, general_state, expected_return,
                            retries_500=0, max_timeout=0):
    """Tests whether we return the correct value based on tree_status."""
    return_status = self._TreeStatusFile(tree_status, general_state)
    self.mox.StubOutWithMock(urllib, 'urlopen')
    status_url = 'https://chromiumos-status.appspot.com/current?format=json'
    backoff = 1
    sleep_timeout = 1
    for _attempt in range(retries_500):
      urllib.urlopen(status_url).AndReturn(return_status)
      return_status.getcode().AndReturn(500)
      time.sleep(backoff)
      backoff *= 2

    urllib.urlopen(status_url).MultipleTimes().AndReturn(return_status)
    # Time is checked twice to bootstrap.
    start_time = 1
    self.mox.StubOutWithMock(time, 'time')
    time.time().AndReturn(start_time)
    time.time().AndReturn(start_time)

    if expected_return == False:
      for time_plus in xrange(max_timeout + 1):
        time.time().AndReturn(start_time + time_plus)
      self.mox.StubOutWithMock(cros_build_lib, 'Info')
      cros_build_lib.Info(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes()
      time.sleep(sleep_timeout).MultipleTimes()

    return_status.getcode().MultipleTimes().AndReturn(200)
    return_status.read().MultipleTimes().AndReturn(return_status.json)
    self.mox.ReplayAll()
    self.assertEqual(cros_build_lib.TreeOpen(status_url, sleep_timeout,
                                             max_timeout), expected_return)
    self.mox.VerifyAll()
开发者ID:hinike,项目名称:opera,代码行数:34,代码来源:cros_build_lib_unittest.py


示例14: getTiempo

def getTiempo():
	dicc = {}
	code = urllib.urlopen("http://weather.yahooapis.com/forecastrss?w=468739&u=c")
	tempsmn = urllib.urlopen("http://www.smn.gov.ar/layouts/temperatura_layout.php").read().decode('iso-8859-1').encode("utf-8").split("º")[0]
	parse = et.parse(code)
	root = parse.getroot()
	tiempo = root[0][12][5].attrib

	dicc['temperatura'] = str(tempsmn)
	if (dicc['temperatura'] == ""):
		print getTime(), "[Tiempo] ADV: Temperatura de Yahoo"
		dicc['temperatura'] = str(tiempo['temp'])

	estadosArray = ['Tornado', 'Tormenta tropical', 'Huracán', "Tormentas fuertes", "Tormenta", "Lluvia y nieve", "Lluvia y aguanieve", "Aguanieve y nieve", "Llovizna helada", "Llovizna", "Lluvia helada", "Lluvia", "Lluvia", "Copos de nieve", "Lluvia ligera", "Nieve y viento", "Nieve", "Granizo", "Aguanieve", "Polvo", "Brumoso", "Neblina", "Humo", "Un poco ventoso", "Ventoso", "Frío", "Nublado", "Parcialmente nublado", "Parcialmente nublado", "Un poco nublado", "Un poco nublado", "Despejado", "Soleado", "Templado", "Templado", "Lluvia con piedras", "Caluroso", "Tormentas aisladas", "Tormentas dispersas", "Tormentas dispersas", "Lluvias Dispersas", "Fuertes Nevadas", "Nevada Leve Dispersa", "Fuertes Nevadas", "Parcialmente Nublado", "Chaparrón", "Nevada Leve", "Chaparrones Aislados"]
	dicc['estado'] = estadosArray[int(tiempo['code'])]
	dicc['icono'] = 'http://l.yimg.com/a/i/us/nws/weather/gr/'+ str(tiempo['code']) + dayOrNight(tiempo['date']) + '.png'

	dicc['minima'] = root[0][12][7].attrib['low']
	dicc['maxima'] = root[0][12][7].attrib['high']

	pronextarray = []
	dicc['extendido'] = pronextarray
	for x in range(8,12):
		pronextarray.append({"dia" : root[0][12][x].attrib['day'], "fecha" : root[0][12][x].attrib['date'], "minima" : root[0][12][x].attrib['low'], "maxima" : root[0][12][x].attrib['high'], "estado" : estadosArray[int(root[0][12][x].attrib['code'])], "icono" : 'http://l.yimg.com/a/i/us/nws/weather/gr/'+ str(root[0][12][x].attrib['code']) + 'd.png'})

	jsonString = json.dumps(dicc)

	jsonFile = open("../servicios/tiempo/serv.json", 'w')
	jsonFile.write(jsonString)
	jsonFile.close()
	print getTime(), "[Tiempo] JSON editado"
	threading.Timer(1800.0, getTiempo).start()
开发者ID:asp95,项目名称:hoyllego,代码行数:32,代码来源:backend.py


示例15: _stop_server

 def _stop_server(cls):
     import urllib # Yup, that's right.
     try:
         urllib.urlopen(cls.scheme + '://' + cls.host + ':' + str(cls.port) + '/shutdown')
     except IOError:
         pass
     cls.server_thread.join()
开发者ID:atykhonov,项目名称:fget,代码行数:7,代码来源:testcase.py


示例16: ping_google

def ping_google(sitemap_url=None, ping_url=PING_URL):
    """
    Alerts Google that the sitemap for the current site has been updated.
    If sitemap_url is provided, it should be an absolute path to the sitemap
    for this site -- e.g., '/sitemap.xml'. If sitemap_url is not provided, this
    function will attempt to deduce it by using urlresolvers.reverse().
    """
    if sitemap_url is None:
        try:
            # First, try to get the "index" sitemap URL.
            sitemap_url = urlresolvers.reverse('django.contrib.sitemaps.views.index')
        except urlresolvers.NoReverseMatch:
            try:
                # Next, try for the "global" sitemap URL.
                sitemap_url = urlresolvers.reverse('django.contrib.sitemaps.views.sitemap')
            except urlresolvers.NoReverseMatch:
                pass

    if sitemap_url is None:
        raise SitemapNotFound("You didn't provide a sitemap_url, and the sitemap URL couldn't be auto-detected.")

    from django.contrib.sites.models import Site
    current_site = Site.objects.get_current()
    url = "http://%s%s" % (current_site.domain, sitemap_url)
    params = urllib.urlencode({'sitemap':url})
    urllib.urlopen("%s?%s" % (ping_url, params))
开发者ID:AloneRoad,项目名称:Inforlearn,代码行数:26,代码来源:__init__.py


示例17: parseFeed

def parseFeed():
    linklist = []
    info = []
    d = feedparser.parse('http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&output=rss')
    feedlink = d.feed.link
    site = urllib.urlopen(feedlink).read()
    parsed = parser.feed(site)
    j = 0
    foundlinks = False
    for line in parsed:
        #if foundlinks:
            #print line
        if "attr" in line and "links" in line:
            foundlinks = True
            print line
    links = []
    i = 2
    x = 0
    for link in links:
        linklist.append(link.firstChild.nodeValue)
        page = urllib.urlopen(link.firstChild.nodeValue).read()
        info.append(re.search('h',page))
        i = i - 1
        if i == 0:
            break
    #for item in info:
    #   x = x+1
    return info
开发者ID:stuycs-softdev-2012-2013,项目名称:mini-projects,代码行数:28,代码来源:nathanielbiggs6.py


示例18: main

def main():
  
  search_str = sys.argv[1]
  movie_ID_list = []
  pair=[]
  calls = 0
  
  #movie_ID_name
  movie_ID_name_csv.write("Id,Label\n")
  for i in range(1,7):
    if (calls == 4):
      time.sleep(1)
    response = urllib.urlopen(search_url+str(i))
    calls = (calls+1)%5
    data = json.loads(response.read())
    #print "ID: ",data["movies"][0]["id"],", Title: ",data["movies"][0]["title"]
    for movie in data["movies"]:
      movie_ID_name.write(movie["id"]+","+movie["title"]+"\n")
      movie_ID_name_csv.write(movie["id"]+","+movie["title"]+"\n")
      movie_ID_list.append(movie["id"])

  #movie_ID_sim_movie_ID
  movie_ID_sim_movie_ID_csv.write("Source,Target,Type\n")
  for movie_id in movie_ID_list:
    if (calls == 4):
      time.sleep(1)
    response = urllib.urlopen(sim_url1+movie_id+sim_url2)
    calls = (calls+1)%5
    data = json.loads(response.read())
    for movie in data["movies"]:
      if([movie["id"],movie_id] in pair):
        continue
      movie_ID_sim_movie_ID.write(movie_id+","+movie["id"]+"\n")
      movie_ID_sim_movie_ID_csv.write(movie_id+","+movie["id"]+",Undirected\n")
      pair.append([movie_id,movie["id"]])
开发者ID:deepurake,项目名称:Acads,代码行数:35,代码来源:movies.py


示例19: requires

def requires():
        print "** COORDINATOR **"
       # print redwood_host
        ctx = ssl.create_default_context()
        ctx.check_hostname = False
        ctx.verify_mode = ssl.CERT_NONE
        # now query the metadata service so I have the mapping of bundle_uuid & file names -> file_uuid
        print str("https://"+redwood_host+":8444/entities?page=0")
        json_str = urlopen(str("https://"+redwood_host+":8444/entities?page=0"), context=ctx).read()
        metadata_struct = json.loads(json_str)
        print "** METADATA TOTAL PAGES: "+str(metadata_struct["totalPages"])
        for i in range(0, metadata_struct["totalPages"]):
            print "** CURRENT METADATA TOTAL PAGES: "+str(i)
            json_str = urlopen(str("https://"+redwood_host+":8444/entities?page="+str(i)), context=ctx).read()
            metadata_struct = json.loads(json_str)
            for file_hash in metadata_struct["content"]:
                bundle_uuid_filename_to_file_uuid[file_hash["gnosId"]+"_"+file_hash["fileName"]] = file_hash["id"]

        #print bundle_uuid_filename_to_file_uuid
                # HACK!!!  Please remove once the behavior has been fixed in the workflow!!
                if file_hash["fileName"].endswith(".sortedByCoord.md.bam"):
                    bundle_uuid_filename_to_file_uuid[file_hash["gnosId"] + "_sortedByCoord.md.bam"] = file_hash[
                        "id"]
                if file_hash["fileName"].endswith(".tar.gz"):
                    bundle_uuid_filename_to_file_uuid[file_hash["gnosId"] + "_tar.gz"] = file_hash[
                        "id"]
                if file_hash["fileName"].endswith(".wiggle.bg"):
                    bundle_uuid_filename_to_file_uuid[file_hash["gnosId"] + "_wiggle.bg"] = file_hash[
                        "id"]
开发者ID:BD2KGenomics,项目名称:dcc-storage-schemas,代码行数:29,代码来源:es_filebrowser_index.py


示例20: Configure

    def Configure(self, prefix="XBMC-Event", xbmcip="192.168.1.1", xbmchttpport=8080, zone="224.0.0.2", port=8278, selfXbmceventbroadcast=False, payDelim="<b></b>"):
        panel = eg.ConfigPanel(self)

        editCtrl = panel.TextCtrl(prefix)
        xbmcipCtrl = panel.TextCtrl(xbmcip)
        xbmchttpportCtrl = panel.SpinIntCtrl(xbmchttpport, min=1, max=65535)
        zoneCtrl = panel.TextCtrl(zone)
        portCtrl = panel.SpinIntCtrl(port, min=1, max=65535)
        selfXbmceventbroadcastCtrl=panel.CheckBox(selfXbmceventbroadcast)
        payDelimCtrl = panel.TextCtrl(payDelim)

        panel.AddLine(self.text.eventPrefix, editCtrl)
        panel.AddLine(self.text.xbmcip, xbmcipCtrl)
        panel.AddLine(self.text.xbmchttpport, xbmchttpportCtrl)
        panel.AddLine(self.text.zone, zoneCtrl)
        panel.AddLine(self.text.port, portCtrl)

        panel.AddLine(self.text.selfXbmceventbroadcast,selfXbmceventbroadcastCtrl)
        panel.AddLine("Payload Delimiter", payDelimCtrl)

        while panel.Affirmed():
            panel.SetResult(editCtrl.GetValue(),xbmcipCtrl.GetValue(),int(xbmchttpportCtrl.GetValue()),zoneCtrl.GetValue(),int(portCtrl.GetValue()),selfXbmceventbroadcastCtrl.GetValue(), payDelimCtrl.GetValue() )
            v_header = urllib.quote("This is the Header")

            v_message = urllib.quote("This is the Message")

	    host_xbmc = xbmcipCtrl.GetValue()
	    port_xbmc = int(xbmchttpportCtrl.GetValue())
	    udp_xbmc = int(portCtrl.GetValue())
	    url_xbmc = "http://" + str(host_xbmc) + ":" + str(port_xbmc) + "/xbmcCmds/xbmcHttp?command=SetBroadcast&parameter=2;" + str(udp_xbmc) + "(Notification(" + v_header + "," + v_message + "))"
            print "str(url_xbmc)"
	    try:
				urllib.urlopen(url_xbmc)
	    except IOError:
				print 'Connection error'
开发者ID:garbear,项目名称:EventGhost,代码行数:35,代码来源:__init__.py



注:本文中的urllib.urlopen函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python urllib.urlquote函数代码示例发布时间:2022-05-27
下一篇:
Python urllib.urllib_quote函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap