テスト用のあれこれ共用フォルダ
修订版 | 78dd56128126090f9d57df8afd624b10ad69471a (tree) |
---|---|
时间 | 2018-03-09 07:56:08 |
作者 | takemasa <suikan@user...> |
Commiter | takemasa |
Added thinkpad power watching by python
@@ -5,7 +5,5 @@ | ||
5 | 5 | </pydev_pathproperty> |
6 | 6 | <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 3.0</pydev_property> |
7 | 7 | <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> |
8 | -<pydev_pathproperty name="org.python.pydev.PROJECT_EXTERNAL_SOURCE_PATH"> | |
9 | -<path>/home/takemasa/shared_foo/vhdl_my_lib/packages_model_py/src</path> | |
10 | -</pydev_pathproperty> | |
8 | + | |
11 | 9 | </pydev_project> |
@@ -0,0 +1,17 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<projectDescription> | |
3 | + <name>power</name> | |
4 | + <comment></comment> | |
5 | + <projects> | |
6 | + </projects> | |
7 | + <buildSpec> | |
8 | + <buildCommand> | |
9 | + <name>org.python.pydev.PyDevBuilder</name> | |
10 | + <arguments> | |
11 | + </arguments> | |
12 | + </buildCommand> | |
13 | + </buildSpec> | |
14 | + <natures> | |
15 | + <nature>org.python.pydev.pythonNature</nature> | |
16 | + </natures> | |
17 | +</projectDescription> |
@@ -0,0 +1,9 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
2 | +<?eclipse-pydev version="1.0"?><pydev_project> | |
3 | +<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> | |
4 | +<path>/${PROJECT_DIR_NAME}</path> | |
5 | +<path>/${PROJECT_DIR_NAME}/src</path> | |
6 | +</pydev_pathproperty> | |
7 | +<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 3.0</pydev_property> | |
8 | +<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> | |
9 | +</pydev_project> |
@@ -0,0 +1,38 @@ | ||
1 | +''' | |
2 | +Created on 2018/03/09 | |
3 | + | |
4 | +@author: takemasa | |
5 | +''' | |
6 | +from _datetime import datetime | |
7 | + | |
8 | +if __name__ == '__main__': | |
9 | + #テキストファイルの読み込み | |
10 | + with open("/sys/class/power_supply/BAT0/energy_now", "r") as f: # 電池内部のエネルギー残量[W] | |
11 | + data = f.read() # ひとまとまりのデータとして読み込む | |
12 | + | |
13 | + data = data.split("\n") # 改行コードで1行ずつに分割 | |
14 | + energy_now = int(data[0])/1000000 | |
15 | + | |
16 | + with open("/sys/class/power_supply/BAT0/energy_full", "r") as f: # 充電可能なエネルギー[w] | |
17 | + data = f.read() # ひとまとまりのデータとして読み込む | |
18 | + | |
19 | + data = data.split("\n") # 改行コードで1行ずつに分割 | |
20 | + energy_full = int(data[0])/1000000 | |
21 | + | |
22 | + with open("/sys/class/power_supply/BAT0/voltage_now", "r") as f: # 電圧 | |
23 | + data = f.read() # ひとまとまりのデータとして読み込む | |
24 | + | |
25 | + data = data.split("\n") # 改行コードで1行ずつに分割 | |
26 | + voltage_now = int(data[0])/1000000 | |
27 | + | |
28 | + with open("/sys/class/power_supply/BAT0/model_name", "r") as f: #モデル名 | |
29 | + data = f.read() # ひとまとまりのデータとして読み込む | |
30 | + | |
31 | + data = data.split("\n") # 改行コードで1行ずつに分割 | |
32 | + model_name = data[0] | |
33 | + | |
34 | +# d = datetime.now().strftime("%Y/%b/%d %X") | |
35 | + d = datetime.now().isoformat() | |
36 | + | |
37 | + # model, time, full, energy now, voltage | |
38 | + print([model_name, d, energy_full, energy_now, voltage_now]) | |
\ No newline at end of file |
@@ -3,6 +3,6 @@ | ||
3 | 3 | <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> |
4 | 4 | <path>/${PROJECT_DIR_NAME}</path> |
5 | 5 | </pydev_pathproperty> |
6 | -<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property> | |
6 | +<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 3.0</pydev_property> | |
7 | 7 | <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> |
8 | 8 | </pydev_project> |
@@ -3,31 +3,31 @@ | ||
3 | 3 | |
4 | 4 | from math import sin, pi |
5 | 5 | |
6 | -print "hello, world" | |
6 | +print ("hello, world") | |
7 | 7 | |
8 | 8 | a = ["alpha", "beta", "gamma"] |
9 | -print type(a) | |
9 | +print (type(a)) | |
10 | 10 | |
11 | 11 | for x in a: |
12 | - print x | |
12 | + print( x) | |
13 | 13 | |
14 | 14 | b = "alpha", "beta", "gamma" |
15 | -print type(b) | |
15 | +print (type(b)) | |
16 | 16 | |
17 | 17 | for x in b: |
18 | - print x | |
18 | + print (x) | |
19 | 19 | |
20 | 20 | for x in b: |
21 | 21 | for y in x: |
22 | - print y | |
22 | + print (y) | |
23 | 23 | |
24 | -print "alpha" in a | |
25 | -print "alpha" in b | |
24 | +print ("alpha" in a) | |
25 | +print ("alpha" in b) | |
26 | 26 | |
27 | -print type(sin) | |
27 | +print (type(sin)) | |
28 | 28 | |
29 | -print pi, sin(pi) | |
29 | +print (pi, sin(pi)) | |
30 | 30 | |
31 | 31 | |
32 | 32 | |
33 | -print "Testing Python" | |
33 | +print ("Testing Python") |
@@ -1,5 +1,5 @@ | ||
1 | 1 | #! /usr/bin/python3 |
2 | 2 | #coding: utf-8 |
3 | 3 | |
4 | -if __name__ == "__main__" : | |
5 | - print( "Testing Python" ) | |
4 | +#if __name__ == "__main__" : | |
5 | +print( "Testing Python" ) |
@@ -0,0 +1,13 @@ | ||
1 | +#! /usr/bin/python3 | |
2 | + | |
3 | +if __name__ == "__main__" : | |
4 | + print( "This is main" ) | |
5 | + | |
6 | + | |
7 | + | |
8 | +f = open('/sys/class/power_supply/BAT0/power_now', 'r') | |
9 | + | |
10 | +for line in f: | |
11 | + print( line,) | |
12 | + | |
13 | +f.close() |