Beispiel #1
0
def device_probe_all(mia, operid, dummy):

    def get_device_list():
        hd_list = filter(lambda d: d.type != parted.DEVICE_DM, parted.getAllDevices())
        
        return hd_list

    mia.set_step(operid, 0, -1)
    result = []
    # The following commented code is implemented by kudzu.
    devlist = get_device_list()
    if devlist:
        for dev in devlist:
            newdisklabel = None
            try:
                disk = parted.Disk(dev)
            except _ped.DiskLabelException:
                # For the disk without any disk label, create it.
                # disk label is disk partition table format
                dltype = parted.diskType['msdos']
                disk = parted.freshDisk(device=dev, ty=dltype)
                #newdisklabel = 'y'
                #disk = dev.disk_new_fresh(parted.disk_type_get('msdos'))
            # Model might contain GB2312, it must be convert to Unicode.
            model = iconv.iconv('gb2312', 'utf8', dev.model).encode('utf8')
            result.append((dev.path, dev.length, model))
            CONF.RUN.g_all_harddisks[dev.path] = (dev, disk, newdisklabel)
    #dolog('operations.parted.device_probe_all: %s\n' % str(result))
    return  result
Beispiel #2
0
def device_probe_all(mia, operid, dummy):
    def get_device_list():
        hd_list = filter(lambda d: d.type != parted.DEVICE_DM and \
                         d.readOnly != True, # CD-ROM will be read only. 
                         parted.getAllDevices())

        return hd_list

    mia.set_step(operid, 0, -1)
    result = []
    # The following commented code is implemented by kudzu.
    devlist = get_device_list()
    if devlist:
        for dev in devlist:
            newdisklabel = None
            try:
                disk = parted.Disk(dev)
            except _ped.DiskLabelException:
                # For the disk without any disk label, create it.
                # disk label is disk partition table format
                dltype = parted.diskType['msdos']
                disk = parted.freshDisk(device=dev, ty=dltype)
                #newdisklabel = 'y'
                #disk = dev.disk_new_fresh(parted.disk_type_get('msdos'))
            # Model might contain GB2312, it must be convert to Unicode.
            model = iconv.iconv('gb2312', 'utf8', dev.model).encode('utf8')
            result.append((dev.path, dev.length, model))
            CF.S.all_harddisks[dev.path] = (dev, disk, newdisklabel)
    dolog('operations.parted.device_probe_all: %s\n' % str(result))
    return result
Beispiel #3
0
    def gettext(self, string):
        if len(self.cats) == 0:
            return string

        translation = None
        for domain in self.domains:
            if not self.cats.has_key(domain):
                continue
            (cat, iconv) = self.cats[domain]
            translation = cat._catalog.get(string)
            if translation is not None:
                if self.conversion:
                    return iconv.iconv(translation)
                else:
                    return translation.encode("UTF-8")

        return string
Beispiel #4
0
for id in range(1,5):
   url = 'http://redking.blog.51cto.com/all/27212/5/page/%s' % id
   pool = urllib3.PoolManager()
   r = pool.request('GET', url, assert_same_host=False)
   title_url = re.findall("<span class=\"artList_tit\">.*?\/a>", r.data, re.S)
   title_urls.extend(title_url)

for i in title_urls:
    pre_url = re.findall(r'href=[\'"]?([^">]+)', i)
    title = re.findall(r'\d+">?([^"<]+)', i)
    if str(pre_url[0]).startswith('/'):
        url  = 'http://redking.blog.51cto.com' + pre_url[0]
    else:
        url = 'http://redking.blog.51cto.com/' + pre_url[0]
    print 'now start sprid the page'
    print str(url),iconv('gb2312','utf-8',title[0])
    u_conn = MySQLdb.connect("localhost","root","123456","test",charset="utf8",init_command="set names utf8")
    cursor = u_conn.cursor()
    s_sql = "select id from url where url=%s"
    id = cursor.execute(s_sql,str(url))
    if int(id) == 0:  
        u_sql = "insert into url (url, title) values  (%s,%s)"
        m_sql = "insert into img (title,imgvalue) values (%s,%s)"
        data = (str(url),iconv('gb2312','utf-8',title[0]))
        cursor.execute(u_sql,data) 
#        u_conn.close()
        
        blog_url = str(url)
        c = initCurl()
	html = GetDate(c, blog_url)
	html = iconv('gb2312','utf-8',html)
Beispiel #5
0
for id in range(1, 5):
    url = 'http://redking.blog.51cto.com/all/27212/5/page/%s' % id
    pool = urllib3.PoolManager()
    r = pool.request('GET', url, assert_same_host=False)
    title_url = re.findall("<span class=\"artList_tit\">.*?\/a>", r.data, re.S)
    title_urls.extend(title_url)

for i in title_urls:
    pre_url = re.findall(r'href=[\'"]?([^">]+)', i)
    title = re.findall(r'\d+">?([^"<]+)', i)
    if str(pre_url[0]).startswith('/'):
        url = 'http://redking.blog.51cto.com' + pre_url[0]
    else:
        url = 'http://redking.blog.51cto.com/' + pre_url[0]
    print 'now start sprid the page'
    print str(url), iconv('gb2312', 'utf-8', title[0])
    u_conn = MySQLdb.connect("localhost",
                             "root",
                             "123456",
                             "test",
                             charset="utf8",
                             init_command="set names utf8")
    cursor = u_conn.cursor()
    s_sql = "select id from url where url=%s"
    id = cursor.execute(s_sql, str(url))
    if int(id) == 0:
        u_sql = "insert into url (url, title) values  (%s,%s)"
        m_sql = "insert into img (title,imgvalue) values (%s,%s)"
        data = (str(url), iconv('gb2312', 'utf-8', title[0]))
        cursor.execute(u_sql, data)
        #        u_conn.close()