Skip to contentSkip to conversation

Issue reading files under /proc/acpi using python.

DISCUSSION Srihari Vijayaraghavan 6 participants 11 messages Feb 6, 2003 – Feb 9, 2003 6 messages not in the archive ACPI

lore
Share & tools
lore
#0 lore raw

Hello,

While I can read /proc/acpi files fine using 'cat', python is unable to read files under that directory.

Here is how you can reproduce the issue:

$ cat /proc/acpi/battery/BAT0/info
present:                 yes
design capacity:         65120 mWh
last full capacity:      61627 mWh
battery technology:      rechargeable
design voltage:          14800 mV
design capacity warning: 6156 mWh
design capacity low:     0 mWh
capacity granularity 1:  1480 mWh
capacity granularity 2:  1480 mWh
model number:            4000
serial number:           1
battery type:
OEM info:                 COMPAQ
$
$ cat /proc/version
Linux version 2.4.21-pre4-acpi (hari-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]) (gcc version 3.2 
20020903 (Red Hat Linux 8.0 3.2-7)) #1 Thu Feb 6 00:12:06 EST 2003
$
$ python
Python 2.2.1 (#1, Aug 30 2002, 12:15:30)
[GCC 3.2 20020822 (Red Hat Linux Rawhide 3.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Quoted 1 line
Quoted 1 line
Quoted 1 line

file("/proc/acpi/battery/BATO/info").read()

Traceback (most recent call last):
File "<stdin>", line 1, in ?
IOError: [Errno 2] No such file or directory: '/proc/acpi/battery/BATO/info'

Quoted 1 line
Quoted 1 line
Quoted 1 line

file("/proc/version").read()

'Linux version 2.4.21-pre4-acpi (hari-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]) (gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)) #1 Thu Feb 6 00:12:06 EST 2003\n'

Quoted 1 line
Quoted 1 line
Quoted 1 line

Softwares involved:
Kernel: Linux-2.4.21-pre4 + acpi-20030125-2.4.21-pre3.diff.gz Rest all as in Red Hat 8.0 (with official updates)
(BTW same behavior is observed with Red Hat beta 8.1, which has updated versions of gcc, glibc, python etc..)

It will be great if I can read all the ascii text files under /proc/acpi using python, like /proc/cpuinfo, /proc/meminfo, /proc/version etc.. files.

Thanks

Signature · 9 lines
Hari
harisri-bzGI/[email protected]



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld =Something 2 See!
http://www.vasoftware.com
#1 lore raw
Quoted 3 lines · Srihari Vijayaraghavan
$ python
Python 2.2.1 (#1, Aug 30 2002, 12:15:30)
[GCC 3.2 20020822 (Red Hat Linux Rawhide 3.2-4)] on linux2

i just tested with a 2.2.2 and it works flawless...

Signature · 8 lines
http://www.chmouel.com/



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com

A message that is not in the archive (sent off-list or not yet received): 200302062245.44847.harisri-bzGI/[email protected]

#3 lore raw
Quoted 6 lines · * Srihari Vijayaraghavan (harisri-bzGI/[email protected])…

While I can read /proc/acpi files fine using 'cat', python is unable to read files under that directory.

Here is how you can reproduce the issue:

$ cat /proc/acpi/battery/BAT0/info

[snip]

Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

file("/proc/acpi/battery/BATO/info").read()

Traceback (most recent call last):
File "<stdin>", line 1, in ?
IOError: [Errno 2] No such file or directory: '/proc/acpi/battery/BATO/info'

Quoted 1 line
Quoted 1 line
Quoted 1 line

file("/proc/version").read()

well BATO != BAT0... you're using a capital o (letter) instead of a 0 (number)

Greetings,
Sergio Visinoni

-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com

A message that is not in the archive (sent off-list or not yet received): 20030206133039.A10882-mRUH1VNo/yu/[email protected]

#5 lore raw

Hello Everyone,

Quoted 4 lines · Sergio Visinoni

[...]
well BATO != BAT0... you're using a capital o (letter) instead of a 0 (number)
[...]

My mistake, I can't apologies enough. :)

I learned my lesson, I should not rely too heavily on bash's command completion feature! (Had I typed the directory structure by hand at least once, I would have known the difference between 0 (numeric) and O (alphabet) )

Everything is fine.

Thanks everyone, and keep up your good work on Linux-ACPI.

Signature · 10 lines
Hari
harisri-bzGI/[email protected]




-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld =Something 2 See!
http://www.vasoftware.com

A message that is not in the archive (sent off-list or not yet received): 200302062343.38789.harisri-bzGI/[email protected]

#7 lore raw
Quoted 8 lines · Srihari Vijayaraghavan

Hello Everyone,

Quoted 4 lines · Sergio Visinoni

[...]
well BATO != BAT0... you're using a capital o (letter) instead of a 0 (number)
[...]

Quoted 7 lines

My mistake, I can't apologies enough. :)

I learned my lesson, I should not rely too heavily on bash's command completion feature! (Had I typed the directory structure by hand at least once, I would have known the difference between 0 (numeric) and O (alphabet) )

BTW, you want to write a generic python acpi class, do you ?

Signature · 10 lines
Ducrot Bruno

--  Which is worse:  ignorance or apathy?
--  Don't know.  Don't care.


-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com

A message that is not in the archive (sent off-list or not yet received): 20030206140059.GR1205-j6u/t2rXLliUoIHC/UFpr9i2O/[email protected]

#9 lore raw

Hello Ducrot,

Quoted 2 lines · Ducrot Bruno

[...]
BTW, you want to write a generic python acpi class, do you ?

While I am no python guru (not just yet), I hope to write a text based utility (great if it is a GUI one) in python to display things like:
1. Battery charge remaining
2. AC adapter status
3. Thermal information
4. etc..
(In fact I have written a text based python utility to display some of those by reading /proc/acpi files). I can send you that in a private e-mail if you wish, it isn't complete yet though.

The real problem is KDE 3.0.x in RH 8.0 doesn't work with newer ACPI code, of course I have verified that KDE 3.1 on Rh 8.1 Beta works fine however. I guess I am lazy to find a utility in the internet that could do that under RH 8.0.

Anyway if you know of any open-source code in python that would help me, please provide me an URL if you can.

Thanks for your help.

Signature · 9 lines
Hari
harisri-bzGI/[email protected]



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld =Something 2 See!
http://www.vasoftware.com

A message that is not in the archive (sent off-list or not yet received): 200302080009.18002.harisri-bzGI/[email protected]

#11 lore raw
Quoted 6 lines · Srihari Vijayaraghavan

Hello Ducrot,

Quoted 2 lines · Ducrot Bruno

[...]
BTW, you want to write a generic python acpi class, do you ?

Quoted 9 lines

While I am no python guru (not just yet), I hope to write a text based utility (great if it is a GUI one) in python to display things like:
1. Battery charge remaining
2. AC adapter status
3. Thermal information
4. etc..
(In fact I have written a text based python utility to display some of those by reading /proc/acpi files). I can send you that in a private e-mail if you wish, it isn't complete yet though.

Yep, if you can provide me some codes in Python in that area, I will be really happy!
I am not a great python guru, though.

Quoted 8 lines

The real problem is KDE 3.0.x in RH 8.0 doesn't work with newer ACPI code, of course I have verified that KDE 3.1 on Rh 8.1 Beta works fine however. I guess I am lazy to find a utility in the internet that could do that under RH 8.0.

Anyway if you know of any open-source code in python that would help me, please provide me an URL if you can.

Well.. Sorry, I am not aware of such URL, but I guess it would be just fine to have a generic acpi class under python (I don't have time to do it myself at this time, even though I have some ideas on how to implement such class).

Cheers,

Signature · 10 lines
Ducrot Bruno

--  Which is worse:  ignorance or apathy?
--  Don't know.  Don't care.


-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
#12 lore raw
In reply to a message not in the archive

Hello,
there exists a patch for the klaptopdaemon, which is in kdeutils-src.rpm on Redhat 8.0 CD 5, you can get from the ACPI-Sourceforge-Homepage. It worked well for me.
Axel

<-snip->

Quoted 5 lines

The real problem is KDE 3.0.x in RH 8.0 doesn't work with newer ACPI code, of course I have verified that KDE 3.1 on Rh 8.1 Beta works fine however. I guess I am lazy to find a utility in the internet that could do that under RH 8.0.

<-snip->

--
Dipl.Phys. Axel Müller (axel.mueller-qenKrGB1/[email protected]) Institut für Werkstoffe der Elektrotechnik IWE
Universität Karlsruhe
Tel. 0721/608-7569 Fax 0721/608-7492
http://www.iwe.uni-karlsruhe.de

-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld =Something 2 See!
http://www.vasoftware.com

#13 lore raw

truc pour les francophones sur la liste...

In reply to a message not in the archive
Quoted 6 lines · Sergio Visinoni
Quoted 1 line
$ cat /proc/acpi/battery/BAT0/info

[snip]

Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

file("/proc/acpi/battery/BATO/info").read()

IOError: [Errno 2] No such file or directory: '/proc/acpi/battery/BATO/info'

well BATO != BAT0... you're using a capital o (letter) instead of a 0 (number)

Évidemment, c'est pas BATO! ;)

SCNR...

Stefan :)

-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld =Something 2 See!
http://www.vasoftware.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#15 lore raw

Re: truc pour les francophones sur la liste...

Quoted 5 lines · Stefan Behnel
Quoted 2 lines · Sergio Visinoni
Quoted 1 line
$ cat /proc/acpi/battery/BAT0/info

[snip]

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

file("/proc/acpi/battery/BATO/info").read()

IOError: [Errno 2] No such file or directory:
'/proc/acpi/battery/BATO/info'

well BATO != BAT0... you're using a capital o (letter) instead of a 0 (number)

Évidemment, c'est pas BATO! ;)

Pas certain. "ACPI et OpenFirmware sont dans un BATO..."

Signature · 10 lines
Ducrot Bruno

--  Which is worse:  ignorance or apathy?
--  Don't know.  Don't care.


-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
#16 lore raw
In reply to a message not in the archive
Quoted 7 lines · Srihari Vijayaraghavan

Hello,

While I can read /proc/acpi files fine using 'cat', python is unable to read files under that directory.

Here is how you can reproduce the issue:

Don't know.

I have:

ducrot@novae:~$ python2.2
Python 2.2.1 (#1, Jul 29 2002, 23:15:49) 
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Quoted 1 line
Quoted 1 line
Quoted 1 line

print file("/proc/acpi/battery/BAT1/state").read()

present:                 yes
capacity state:          ok
charging state:          unknown
present rate:            0 mA
remaining capacity:      2040 mAh
present voltage:         14800 mV
Quoted 1 line
Quoted 1 line
Quoted 1 line

print file("/proc/acpi/battery/BAT1/info").read()

present:                 yes
design capacity:         4000 mAh
last full capacity:      4000 mAh
battery technology:      rechargeable
design voltage:          14800 mV
design capacity warning: 420 mAh
design capacity low:     156 mAh
capacity granularity 1:  264 mAh
capacity granularity 2:  3780 mAh
model number:            PA3098U 
serial number:           3658Q
battery type:            Li-Ion
OEM info:                TOSHIBA
Quoted 1 line
Quoted 1 line
Quoted 1 line

print file("/proc/version").read()

Linux version 2.4.21-pre3 (root@novae) (gcc version 2.95.4 (Debian prerelease)) #3 Tue Feb 4 16:30:11 CET 2003

Quoted 1 line
Quoted 1 line
Quoted 1 line
ducrot@novae:~$ python2.2 -V
Python 2.2.1

libc 2.25.

Cheers,

Signature · 10 lines
Ducrot Bruno

--  Which is worse:  ignorance or apathy?
--  Don't know.  Don't care.


-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com