all repos — tint2 @ 405c2c9286a719481de59bda030dd1ee99a5f994

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

test/gather-battery-data.py (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python

import os
import os.path
import tarfile
try:
  from StringIO import StringIO
except ImportError:
  from io import StringIO


class TarWriter:
  def __init__(self, out_name):
    print("Creating: " + out_name)
    self.tar = tarfile.open(out_name, "w")

  def add(self, path):
    print("Adding: " + path)
    if os.path.isfile(path):
      metadata = self.tar.gettarinfo(path)
      try:
        with open(path) as f:
          buf = f.read()
          fbuf = StringIO(buf)
          metadata.size = len(buf)
          self.tar.addfile(metadata, fbuf)
          fbuf.close()
      except:
        fbuf = StringIO()
        metadata.size = 0
        self.tar.addfile(metadata, fbuf)
        fbuf.close()

  def close(self):
    self.tar.close()


writer = TarWriter("battery.tar")
for root, dirs, files in os.walk("/sys/class/power_supply"):
  for device in dirs:
    for root2, dirs2, files2 in os.walk(root + "/" + device):
      for f in files2:
        writer.add(root2 + "/" + f)
writer.close()
print("Finished.")