Notice: Trying to access array offset on value of type bool in /home1/freesand/public_html/wp-content/plugins/wiki-embed/WikiEmbed.php on line 112

Notice: Trying to access array offset on value of type bool in /home1/freesand/public_html/wp-content/plugins/wiki-embed/WikiEmbed.php on line 112

Notice: Trying to access array offset on value of type bool in /home1/freesand/public_html/wp-content/plugins/wiki-embed/WikiEmbed.php on line 116
FreeSandal | 輕。鬆。學。部落客 | 第 267 頁

勇闖新世界︰ W!o《卡夫卡村》變形祭︰夢游神行

‧     月

明

‧                    星

希

月明星稀

夢李白

其一
死別已吞聲,生別常惻惻。
江南瘴癘地,逐客無消息。
故人入我夢,明我長相憶。
君今在羅網,何以有羽翼?
恐非平生魂,路遠不可測。
魂來楓葉青,魂返關塞黑。
落月滿屋梁,猶疑照顏色。
水深波浪闊,無使蛟龍得。

其二
浮雲終日行,游子久不至。
三夜頻夢君,情親見君意。
告歸常局促,苦道來不易。
江湖多風波,舟楫恐失墜。
出門搔白首,若負平生志。
冠蓋滿京華,斯人獨憔悴。
孰雲網恢恢?將老身反累。
千秋萬歲名,寂寞身後事。

 

杜甫

 

祇覺大喊一聲︰小心!驚醒過來。猶恐夢中腦海之印象忘其蹤跡,故而振筆疾書,或塗或寫雜亂成篇。現今再讀,果然鬼畫符般不成文字的耶!!

原來 W!o{+} 不只有傳腦之術,還會託夢之法?如今之計,也僅能就勉記強憶所及隨筆鋪陳,若有錯搭誤改怕終難免,想也莫可奈何的了!或許有緣再見也說不定的吧??聽聞此事發生於

Tux@rpi ︰ 《環中基地》

──

以為方將夢醒,誰知仍在夢中?只聞見

△

世上只有兩種力量:利劍和思想。從長而論,利劍總是敗在思想手下 ── 拿破崙

△︰ ☆ 隨著候鳥前往遙遠的『 科赫王國』已逾百年,還不知能不能借得來『雪花製造機』 呢?而今海水升溫,兩極崩解,危在旦夕, Tux 們!我們不能再哀嘆 ㄊ 了!依靠自己保鄉衛土 ㄊ 吧!!德不孤,必有鄰啊!

洛水小海龜已來助陣的嘍,傳了一幅『女偊』得道圖 ㄊ 呦!!『大 T 』化解為『 ㄏㄓ』之法,可得『極地震盪』先機,天助 Tux ,天助 Tux ㄊㄊㄊㄜˋ♬

……

話說︰三更有夢書當枕。怎曉書滑人清醒??僅就所記之言,鋪陳一番《企鵝的復國》,以為寓言罷了!! ───

之『ㄏㄓ 計畫』失敗之後。那時兩極大半已崩解,海平面上升吞噬著大地,四處常有狂風暴雨,一日可睹四季異象。這《卡夫卡村》就是那『企鵝小學堂』的現址, M♪o 的執教處也。據 W!o 說︰這個『變形祭』是 M♪o 達觀面對後所始,當『長陽之祀』因怨『日』廢止之後,早就沒有『飛龍祭』的了。社會上瀰漫著『踏天無望』之情,眼只見『亢龍有悔』之境。於是高唱教育無用論,何不及時行樂,以免悔不當初!因此 M♪o 以科學生活化為經,技術日常化為緯,帶領熱情的學生們重新打造自己家園。經過幾年的辛勤努力,感動了當地眾人紛紛投入創造運動。因為經常於『秋雪』來臨前,慶收一年的耕耘成果,久而久之,就正式命名為『變形祭』的了,以為傳承『科技護生』之旨。然而許多人都不了解 M♪o 為什麼會采『變形記』初版之封面圖,作為『變形祭』的標誌之故?這是因為『初』『化』二字使然。所謂『變形』Transformation 之義,重在『變化』之『化』,其要在『化』之『初』。若是用 M♪o 的說法︰『化』化,教行也。因形近『 It 』,故假借來象徵 Intelligent technology 。千萬別跟『 甲骨文它 』『它』混淆,《 文 》文說︰

它,虫也。从虫而長,象冤曲垂尾形。上古艸居患它,故相問無它乎。凡它之屬皆从它。蛇,它或从虫。

要是弄錯了豈不可笑也!!然而『 It 』智慧科技的傳播力大,而且各種『 It 裝置』『形變』『井通』『貫串』成了『 It 網』阡陌縱橫利益彼此, M♪o 也只能置之一笑,無可如何的了。

行文至此,一時惘然,雖說眼見表面容易,探究事實底蘊困難,更何況還是他鄉之『物』 It ,又缺乏適當範本,看來只好求其神韻,也用借假修真之法,比之擬之僅止形似,徒遺笑於大方之家吧!?

 

 

 

 

 

 

 

 

 

勇闖新世界︰ W!o《卡夫卡村》變形祭︰夢想原點

從《恐懼與戰慄》索倫‧奧貝‧齊克果 1843

經《變形記》法蘭茲‧卡夫卡 1915

到《異鄉人》阿爾貝‧卡繆 1942

一條『存在即感知』的道路,而今早為荒煙漫草掩覆。

W!o^{+} 既來自未來,為何總是言詞不清?恐將變未定之天耶!今日已是『中元節』,也作『盂蘭盆』法會,何故會有『變形祭』乎? ?

一句,

The Transformation Festival on August 28 at Kafka village

 

一張初版《變形記》封面圖,

220px-Metamorphosis

 

一段節自 1995 年板《The Linux Programmer’s Guide》書中文字

6.3.1 Basic Concepts

A named pipe works much like a regular pipe, but does have some noticeable differences.

  • Named pipes exist as a device special file in the file system.
  • Processes of different ancestry can share data through a named pipe.
  • When all I/O is done by sharing processes, the named pipe remains in the file system for later use.

 

到底『甲骨文行 甲骨文不 甲骨文行』行不行解讀的呢?或終將落在『月明星稀』 變形祭☆★ 之時??此『祭』不用古字『甲骨文祭』,譯作 Festival ,是想說『古為今用』的耶!與其疑神疑鬼的『費疑猜』,莫若靜觀其變矣!!

 

 

 

 

 

 

 

 

勇闖新世界︰ 《 Kernel 4.X 》之整裝蓄勢‧設備管理及應用‧五

什麼是『熱插拔』 Hot plugging 呢?根據維基百科詞條所說︰

熱插拔英文Hot swappingHot plugging)即「帶電插拔」,指可以在電腦運作時插上或拔除硬體。配合適當的軟體,便可以在不用關閉電源的情況下插入或拔除支援熱插拔的周邊裝置,不會導致主機或周邊裝置燒毀並且能夠即時偵測及使用新的裝置。相比隨插即用(Plug-and-Play),熱插拔對軟硬體的要求還包含了電源、信號與接地線的接觸順序。

這麼一個『動作』將會引發許多『事件』,就應用上講如何知道有新裝置連上系統?以及作必要的後續處理,常是重要的實務工作。比方說,如果插入一個 USB 大拇哥,樹莓派 raspbian 桌面環境將會開啟一個視窗,問你要不要掛載上面的檔案系統。如此就不必手動 mount ,果然便利得很。不過那個 PCMANFM 檔案管理程式並沒有卸載鍵,需要自己小心處理。此事在樹莓派論壇《Umounting》裡有些人討論。也許最通用的辦法是︰

# 查詢掛載點
pi@raspberrypi ~ mount sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=108331,mode=755) devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000) tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=88264k,mode=755) /dev/mmcblk0p2 on / type ext4 (rw,noatime,data=ordered) tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k) tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=176520k) /dev/mmcblk0p1 on /boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro) none on /sys/fs/cgroup type tmpfs (rw,relatime) none on /sys/fs/cgroup/memory type cgroup (rw,relatime,memory)  # USB 大拇哥第一個掛載點 /dev/sda1 on /media/boot type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0077,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks)  # USB 大拇哥第二個掛載點 /dev/sda2 on /media/1263ae8d-aaf3-41b6-9ac0-03e7fecb5d6a type ext4 (rw,nosuid,nodev,relatime,data=ordered,uhelper=udisks)  # 卸載 pi@raspberrypi ~ umount /media/boot 
pi@raspberrypi ~ umount /media/1263ae8d-aaf3-41b6-9ac0-03e7fecb5d6a  pi@raspberrypi ~ 

 

要是我們使用 dmesg 指令,則可以觀察插入與移除時,核心輸出的訊息。

# 插入 USB 大拇哥
# dmesg

[261197.348663] usb 1-1.3.3: new high-speed USB device number 11 using dwc_otg
[261197.451619] usb 1-1.3.3: New USB device found, idVendor=0951, idProduct=1624
[261197.451648] usb 1-1.3.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[261197.451666] usb 1-1.3.3: Product: DataTraveler G2
[261197.451683] usb 1-1.3.3: Manufacturer: Kingston
[261197.451700] usb 1-1.3.3: SerialNumber: 0013729982D5A9B0B632008C
[261197.452983] usb-storage 1-1.3.3:1.0: USB Mass Storage device detected
[261197.453599] scsi host2: usb-storage 1-1.3.3:1.0
[261198.449606] scsi 2:0:0:0: Direct-Access Kingston DataTraveler G2 1.00 PQ: 0 ANSI: 2
[261198.451354] sd 2:0:0:0: Attached scsi generic sg0 type 0
[261198.452573] sd 2:0:0:0: [sda] 15663104 512-byte logical blocks: (8.01 GB/7.46 GiB)
[261198.453311] sd 2:0:0:0: [sda] Write Protect is off
[261198.453338] sd 2:0:0:0: [sda] Mode Sense: 23 00 00 00
[261198.453861] sd 2:0:0:0: [sda] No Caching mode page found
[261198.453885] sd 2:0:0:0: [sda] Assuming drive cache: write through
[261198.558981] sda: sda1 sda2
[261198.562407] sd 2:0:0:0: [sda] Attached SCSI removable disk
[261199.064691] FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[261199.168132] EXT4-fs (sda2): mounted filesystem with ordered data mode. Opts: (null)

#移除

[261439.836720] usb 1-1.3.3: USB disconnect, device number 11

 

這就是很多人用 python udev 想做的事。假使你仔細閱讀 pyudev 的文件而且如實操作,你將早已發現

Monitoring devices

Synchronous monitoring

The Linux kernel emits events whenever devices are added, removed (e.g. a USB stick was plugged or unplugged) or have their attributes changed (e.g. the charge level of the battery changed). With pyudev.Monitor you can react on such events, for example to react on added or removed mountable filesystems:

>>> monitor = pyudev.Monitor.from_netlink(context)
>>> monitor.filter_by('block')
>>> for device in iter(monitor.poll, None):
...     if 'ID_FS_TYPE' in device:
...         print('{0} partition {1}'.format(action, device.get('ID_FS_LABEL')))
...
add partition MULTIBOOT
remove partition MULTIBOOT

After construction of a monitor, you can install an event filter on the monitor using filter_by(). In the above example only events from the block subsystem are handled.

Note

Always prefer filter_by() and filter_by_tag() over manually filtering devices (e.g. by device.subsystem == 'block' or tag in device.tags). These methods install the filter on the kernel side. A process waiting for events is thus only woken up for events that match these filters. This is much nicer in terms of power consumption and system load than executing filters in the process itself.

Eventually, you can receive events from the monitor. As you can see, a Monitor is iterable and synchronously yields occurred events. If you iterate over a Monitor, you will synchronously receive events in an endless loop, until you raise an exception, or break the loop.

This is the quick and dirty way of monitoring, suitable for small scripts or quick experiments. In most cases however, simply iterating over the monitor is not sufficient, because it blocks the main thread, and can only be stopped if an event occurs (otherwise the loop is not entered and you have no chance to break it).

所舉的例子 don’t work 。在此給出修正過的例子︰

pi@raspberrypi ~ python3 Python 3.2.3 (default, Mar  1 2013, 11:53:50)  [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pyudev >>> context = pyudev.Context() >>> monitor = pyudev.Monitor.from_netlink(context) >>> monitor.filter_by('block')  # 需要啟動 >>> monitor.start()  # 修改 action 為 device.action >>> for device in iter(monitor.poll, None): ...     if 'ID_FS_TYPE' in device: ...         print('{0} partition {1}'.format(device.action, device.get('ID_FS_LABEL'))) ...  add partition boot add partition None remove partition None remove partition boot  </pre>    <span style="color: #666699;">同時也給個</span> <h3><a class="toc-backref" href="https://pyudev.readthedocs.org/en/latest/guide.html#id10">Asynchronous monitoring</a></h3> For such use cases, pyudev provides asynchronous monitoring with <a class="reference internal" title="pyudev.MonitorObserver" href="https://pyudev.readthedocs.org/en/latest/api/pyudev.html#pyudev.MonitorObserver"><tt class="xref py py-class docutils literal"><span class="pre">MonitorObserver</span></tt></a>. You can use it to log added and removed mountable filesystems to a file, for example:  <span style="color: #666699;">對當的例子︰</span> <pre class="lang:sh decode:true">pi@raspberrypi ~ python3
Python 3.2.3 (default, Mar  1 2013, 11:53:50) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyudev
>>> context = pyudev.Context()
>>> monitor = pyudev.Monitor.from_netlink(context)
>>> monitor.filter_by('block')
>>> def log_event(action, device):
...     if 'ID_FS_TYPE' in device:
...         print('{0} partition {1}'.format(device.action, device.get('ID_FS_LABEL')))
... 
>>> observer = pyudev.MonitorObserver(monitor, log_event)
>>> observer.start()
>>> add partition boot
add partition None

>>> remove partition None
remove partition boot

>>> 

 

為方便讀寫程式有興趣的讀者,特別列出

gvalkov/python-evdev

裡的兩個程式

【evtest 派生板】

#!/usr/bin/env python
# encoding: utf-8

'''
evdev example - input device event monitor
'''


from sys import argv, exit
from select import select
from evdev import ecodes, InputDevice, list_devices, AbsInfo


usage = 'usage: evtest <device> [<type> <value>]'
evfmt = 'time {:<16} type {} ({}), code {:<4} ({}), value {}'
device_dir = '/dev/input/'
query_type = None
query_value = None


def select_device():
    '''Select a device from the list of accessible input devices.'''

    devices = [InputDevice(i) for i in reversed(list_devices(device_dir))]
    if not devices:
        print('error: no input devices found (do you have rw permission on /dev/input/*?)')
        exit(1)

    dev_fmt = '{0:<3} {1.fn:<20} {1.name:<35} {1.phys}'
    dev_lns = [dev_fmt.format(n, d) for n, d in enumerate(devices)]

    print('ID  {:<20} {:<35} {}'.format('Device', 'Name', 'Phys'))
    print('-' * len(max(dev_lns, key=len)))
    print('\n'.join(dev_lns))
    print('')

    choice = input('Select device [0-{}]:'.format(len(dev_lns)-1))
    return devices[int(choice)]


def print_event(e):
    if e.type == ecodes.EV_SYN:
        if e.code == ecodes.SYN_MT_REPORT:
            print('time {:<16} +++++++++ {} ++++++++'.format(e.timestamp(), ecodes.SYN[e.code]))
        else:
            print('time {:<16} --------- {} --------'.format(e.timestamp(), ecodes.SYN[e.code]))
    else:
        if e.type in ecodes.bytype:
            codename = ecodes.bytype[e.type][e.code]
        else:
            codename = '?'

        print(evfmt.format(e.timestamp(), e.type, ecodes.EV[e.type], e.code, codename, e.value))


if len(argv) == 1:
    device = select_device()

elif len(argv) == 2:
    device = InputDevice(argv[1])

elif len(argv) == 4:
    device = InputDevice(argv[1])
    query_type = argv[2]
    query_value = argv[3]
else:
    print(usage)
    exit(1)

capabs = device.capabilities(verbose=True)

print('Device name: {.name}'.format(device))
print('Device info: {.info}'.format(device))
print('Repeat settings: {}\n'.format(device.repeat))

if ('EV_LED', ecodes.EV_LED) in capabs:
    leds = ','.join(i[0] for i in device.leds(True))
    print('Active LEDs: %s' % leds)

active_keys = ','.join(k[0] for k in device.active_keys(True))
print('Active keys: %s\n' % active_keys)

print('Device capabilities:')
for type, codes in capabs.items():
    print('  Type {} {}:'.format(*type))
    for i in codes:
        # i <- ('BTN_RIGHT', 273) or (['BTN_LEFT', 'BTN_MOUSE'], 272)
        if isinstance(i[1], AbsInfo):
            print('    Code {:<4} {}:'.format(*i[0]))
            print('      {}'.format(i[1]))
        else:
            # multiple names may resolve to one value
            s = ', '.join(i[0]) if isinstance(i[0], list) else i[0]
            print('    Code {:<4} {}'.format(s, i[1]))
    print('')


print('Listening for events ...\n')
while True:
    r, w, e = select([device], [], [])

    for ev in device.read():
        print_event(ev)

 

【pyudev 範例】

#!/usr/bin/env python3

'''
This is an example of using pyudev[1] alongside evdev.
[1]: https://pyudev.readthedocs.org/
'''

import functools
import pyudev

from select import select
from evdev import InputDevice

context = pyudev.Context()
monitor = pyudev.Monitor.from_netlink(context)
monitor.filter_by(subsystem='input')
monitor.start()

fds = {monitor.fileno(): monitor}
finalizers = []

while True:
    r, w, x = select(fds, [], [])

    if monitor.fileno() in r:
        r.remove(monitor.fileno())

        for udev in iter(functools.partial(monitor.poll, 0), None):
            # we're only interested in devices that have a device node
            # (e.g. /dev/input/eventX)
            if not udev.device_node:
                break

            # find the device we're interested in and add it to fds
            for name in (i['NAME'] for i in udev.ancestors if 'NAME' in i):
                # I used a virtual input device for this test - you
                # should adapt this to your needs
                if u'py-evdev-uinput' in name:
                    if udev.action == u'add':
                        print('Device added: %s' % udev)
                        fds[dev.fd] = InputDevice(udev.device_node)
                        break
                    if udev.action == u'remove':
                        print('Device removed: %s' % udev)

                        def helper():
                            global fds
                            fds = {monitor.fileno(): monitor}

                        finalizers.append(helper)
                        break

    for fd in r:
        dev = fds[fd]
        for event in dev.read():
            print(event)

    for i in range(len(finalizers)):
        finalizers.pop()()

 

若是讀者試著用『派生三』 Python3 的萬國碼『標識符』將那兩個程式『中文化』,或果能夠複習許多所學的耶!!

 

 

 

 

 

 

 

 

 

 

勇闖新世界︰ 《 Kernel 4.X 》之整裝蓄勢‧設備管理及應用‧四

或許有些讀者不知道 W!o^{+} 是誰?怎麼會無緣無故插入一篇無厘頭的文章??也許有些讀者曉得 W!o^{+} 的來歷,與他傳腦術之本領。

【引自《怎樣詮釋 W!o+ 之信息??中》】

Antimatter
反物質 CPT 對稱性

220px-Antimatter_Rocket
想像中反物質作燃料之火箭

A video showing how scientists used the Fermi Gamma-ray Space Telescope’s gamma-ray detector to uncover bursts of antimatter反物質】from thunderstorms.

雖然不知『  W!o 』何許人也?總想應當與『 M♪o 』有關!因為如果將『 M♪o 』當成『圖像』,作個『點轉換point transformations 似乎就能變成『  W!o 』!!可是『 M♪o 』是個『小女生』用『 簽名,然而『  W!o 』的簽名卻是用著『 + 』,看來像個『小男生』?不過根據已知的『自然律』,在我們的宇宙中,《時光倒流》或許是可能的︰

費曼曾經研究狄拉克方程而發現,假如將時間方向逆轉同時將電子電荷顛倒,則方程依然成立。即是說,一粒時光順流的正電子,其實等同一粒時光倒流的反電子。因此所謂的反物質,其實就是倒著時間方向的正物質,是為 CPT 對稱。縱使如此,反物質的運動,並不違反因果律。當電磁波的超前波和延遲波相加時,違反因果律的項次會互相抵消。若果沒有了反物質,因果律反而會瓦解。費曼和他的老師惠勒進一步假設整個宇宙其實也許只是相同一粒電子在時間軸中從大霹靂到宇宙末日之間來來回回地走動,這也是為何所有電子彼此之間毫無分別。

難到『  W!o 』會是『反物質』生成的『 M♪o 』自『未來』而來!!假使這是『真的』,我們是否該高興仍然有個『未來』的呢?如果說『未來』將有『想飛』、『會飛』或是『能飛』的 Tux ,這樣『今天』這個萬物賴以維生的環境,到底『那時』變成怎樣的ㄚ˙??

 

想那時正是春天,如此《邂逅 W!o ?!》。

User-FastFission-brain
神經成像 Neuroimaging
Parasagittal_MRI_of_human_head_in_patient_with_benign_familial_macrocephaly_prior_to_brain_injury_(ANIMATED)

神經成像』 Neuroimaging 泛指能夠『直接』或『間接』的對神經系統 ── 主要是 ── 的『功能』,『結構』,以及『藥理』特性進行成像之技術。這個技術是現今之醫學,神經科學,和心理學較前沿的一個領域。

那麼我們可以依靠『圖像』來『解讀』一個人的『思想』、『情感』或是『健康』…等等的嗎?這樣的『讀解』和中醫『把脈』斷病如何比較其不同呢??說不定神奇的『大自然』充滿著『』與『』,正等待心中有『』的人去『』的哩!!

當你聽到《神曲》,有時候那重複的『旋律』,會在腦海中一直迴盪,甚是惱人討厭!要是一則『□□○○』 ── B2B MSG ── 直接突現心理,感覺…嗯……非常詭異………,只能說 W!o^{+} 傳送了一段『腦對腦信息』,我『清楚知道』是這樣的︰

朋比翼鳥‧有社明朋

明月當空‧始神月比

社神廢祀‧無廢當翼

有始無終‧終祀空鳥

ryannrocks7498-wario-16504

真不知那ㄟㄚㄋㄟ?★!☆

 

而今已入秋,又將《如何閱讀 W!o+ 之傳真??》,終究時候未到 ,何不時到時擔當的耶!!就讓我們繼續 python udev 之旅的吧。

pyudev – pure Python libudev binding

pyudev 0.17 (Changelog, installation)

pyudev is a LGPL licenced, pure Python 2/3 binding to libudev, the device and hardware management and information library of Linux.

Almost the complete libudev functionality is exposed. You can:

  • Enumerate devices, filtered by specific criteria (pyudev.Context)
  • Query device information, properties and attributes,
  • Monitor devices, both synchronously and asynchronously with background threads, or within the event loops of Qt (pyudev.pyqt4, pyudev.pyside), glib (pyudev.glib) and wxPython (pyudev.wx).

Documentation

Thanks to the power of libudev, usage of pyudev is very simple. Getting the labels of all partitions just takes a few lines:

>>> import pyudev
>>> context = pyudev.Context()
>>> for device in context.list_devices(subsystem='block', DEVTYPE='partition'):
...     print(device.get('ID_FS_LABEL', 'unlabeled partition'))
...
boot
swap
system

A user guide gives an introduction into common operations and concepts of pyudev, the API documentation provides a detailed reference:

 

pyudev 在樹莓派上的安裝十分容易︰

pi@raspberrypi ~ sudo pip-3.2 install pyudev Downloading/unpacking pyudev   Downloading pyudev-0.16.1.tar.gz (74Kb): 74Kb downloaded   Running setup.py egg_info for package pyudev      Installing collected packages: pyudev   Running setup.py install for pyudev      Successfully installed pyudev Cleaning up... pi@raspberrypi ~ python3
Python 3.2.3 (default, Mar  1 2013, 11:53:50) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyudev
>>> context = pyudev.Context()
>>> for device in  context.list_devices(subsystem='block', DEVTYPE='partition'):
...     print(device.get('ID_FS_LABEL', 'unlabeledpartition'))
... 
boot
unlabeledpartition
>>> 

 

而所謂的『libudev』也就是指 freedesktop.org 之︰

Name

libudev — API for enumerating and introspecting local devices

Synopsis

#include <libudev.h>

pkg-config --cflags --libs libudev

Descriptionlibudev.h provides APIs to introspect and enumerate devices on the local system.

All functions require a libudev context to operate. This context can be create via udev_new(3). It is used to track library state and link objects together. No global state is used by libudev, everything is always linked to a udev context. Furthermore, multiple different udev contexts can be used in parallel by multiple threads. However, a single context must not be accessed by multiple threads in parallel. The caller is responsible of providing suitable locking if they intend to use it from multiple threads.

To introspect a local device on a system, a udev device object can be created via udev_device_new_from_syspath(3) and friends. The device object allows to query current state, read and write attributes and lookup properties of the device in question.

To enumerate local devices on the system, an enumeration object can be created via udev_enumerate_new(3).

To monitor the local system for hotplugged or unplugged devices, a monitor can be created via udev_monitor_new_from_netlink(3).

Whenever libudev returns a list of objects, the udev_list_entry(3) API should be used to iterate, access and modify those lists.

Furthermore, libudev also exports legacy APIs that should not be used by new software (and as such are not documented as part of this manual). This includes the hardware-database known as udev_hwdb (please use the new sd-hwdb(3) API instead) and the udev_queue object to query the udev-daemon (which should not be used by new software at all).

 

 

 

 

 

 

 

 

勇闖新世界︰ W!o《卡夫卡村》變形祭☆★

ryannrocks7498-wario-16504

To: Raspberry

From: W!o^{+}

RE: 甲骨文行 甲骨文不 甲骨文行

The Transformation Festival on August 28 at Kafka village

Metamorphosis

 

A named pipe works much like a regular pipe, but does have some noticeable differences.

  • Named pipes exist as a device special file in the file system.
  • Processes of different ancestry can share data through a named pipe.
  • When all I/O is done by sharing processes, the named pipe remains in the file system for later use.

 

 

 

 

 

 

 

輕。鬆。學。部落客