• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

テスト用のあれこれ共用フォルダ


Commit MetaInfo

修订版78dd56128126090f9d57df8afd624b10ad69471a (tree)
时间2018-03-09 07:56:08
作者takemasa <suikan@user...>
Commitertakemasa

Log Message

Added thinkpad power watching by python

更改概述

差异

--- a/python3/packages_testgen_py/.pydevproject
+++ b/python3/packages_testgen_py/.pydevproject
@@ -5,7 +5,5 @@
55 </pydev_pathproperty>
66 <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 3.0</pydev_property>
77 <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+
119 </pydev_project>
--- /dev/null
+++ b/python3/power/.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>
--- /dev/null
+++ b/python3/power/.pydevproject
@@ -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>
--- /dev/null
+++ b/python3/power/src/main.py
@@ -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
--- a/python3/python-test/.pydevproject
+++ b/python3/python-test/.pydevproject
@@ -3,6 +3,6 @@
33 <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
44 <path>/${PROJECT_DIR_NAME}</path>
55 </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>
77 <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
88 </pydev_project>
Binary files a/python3/python-test/__pycache__/collections.cpython-35.pyc and b/python3/python-test/__pycache__/collections.cpython-35.pyc differ
--- a/python3/python-test/collections.py
+++ b/python3/python-test/collections.py
@@ -3,31 +3,31 @@
33
44 from math import sin, pi
55
6-print "hello, world"
6+print ("hello, world")
77
88 a = ["alpha", "beta", "gamma"]
9-print type(a)
9+print (type(a))
1010
1111 for x in a:
12- print x
12+ print( x)
1313
1414 b = "alpha", "beta", "gamma"
15-print type(b)
15+print (type(b))
1616
1717 for x in b:
18- print x
18+ print (x)
1919
2020 for x in b:
2121 for y in x:
22- print y
22+ print (y)
2323
24-print "alpha" in a
25-print "alpha" in b
24+print ("alpha" in a)
25+print ("alpha" in b)
2626
27-print type(sin)
27+print (type(sin))
2828
29-print pi, sin(pi)
29+print (pi, sin(pi))
3030
3131
3232
33-print "Testing Python"
33+print ("Testing Python")
--- a/python3/python-test/hello.py
+++ b/python3/python-test/hello.py
@@ -1,5 +1,5 @@
11 #! /usr/bin/python3
22 #coding: utf-8
33
4-if __name__ == "__main__" :
5- print( "Testing Python" )
4+#if __name__ == "__main__" :
5+print( "Testing Python" )
--- /dev/null
+++ b/python3/python-test/power.py
@@ -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()