← Back to team overview

touch-packages team mailing list archive

[Bug 1336462] Re: Make apport collect some Power information

 

Comment 4, proposed hook:

> if arch in [ "ppc64", "ppc64le"]:
>  print "Processing power %s" %arch

Please use print(...) to be compatible with Python 3. Ubuntu has used
Apport with Python3 for several releases already. Also, please use 4
spaces for indentation, but I can fix such small issues myself when
integrating this into the package, so nevermind that.

> else:
>  print "Not executing power query since arch %s" %arch

print()

>  exit(1)
Please move that entire check to add_info(), and replace the exit(1) with "return".

> def add_copy_spec(path):
>     for file in apport.hookutils.read_file(path):

That won't work with directory names as "path" arguments, they are not
files. If it's a single hierarchy, you can use "for file in
os.listdir(path):", for a fully recursive search you need to use
os.walk(). But please don't attach a gazillion little files; for e. g.
/device-tree/ I suppose you should rather call tar and attach the
tarball only. Or you pre-process it locally to extract a minimum of the
actually interesting information and then only attach that text file.

Same print → print() issue as before.

Please dont' call root_command_output() multiple times, you'll get an
auth prompt for every single one. Do a single call to
attach_root_command_outputs() instead with a mapping of the commands.

Some hints:

You can get help for a Python class, or method with:

$ python3
>>> import apport.hookutils
>>> help(apport.hookutils)

>>> help(apport.hookutils.attach_root_command_outputs)

You can test your hook by putting it into /usr/share/apport/general-
hooks/, then run "ubuntu-bug coreutils" from the CLI and inspect the
details. You'll probably see a lot of exceptions (due to the Python 2
print statement, etc) first. Once you are satisfied wkth the kind of
output you get in the hook, I'm happy to take over and massage the code
a little more for readability/PEP-8/etc.

Thanks!

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to apport in Ubuntu.
https://bugs.launchpad.net/bugs/1336462

Title:
  Make apport collect some Power information

Status in “apport” package in Ubuntu:
  In Progress

Bug description:
  On power/ppc64el system, we would need to enhance current apport reporting tool which some information like file content or commands output including
            "/proc/device-tree/"
              "/proc/loadavg"
              "/proc/locks"
             "/proc/misc"
              "/proc/swaps"
              "/proc/version"
              "/dev/nvram"
              "/var/log/platform"
              "ppc64_cpu --smt"
              "ppc64_cpu --cores-present"
              "ppc64_cpu --cores-on"
              "ppc64_cpu --run-mode"
             "ppc64_cpu --frequency"
             "ppc64_cpu --dscr"

  Readme says : For complete instructions, see /usr/share/doc/apport/package-hooks.txt but
  cat: /usr/share/doc/apport/package-hooks.txt: No such file or directory

  Do I understand correctly I would need to create a file (for example)
  named : /usr/share/apport/general-hooks/power.py ?

  Other questions:
  Do you have common functions to put output of commands in logfile ?
  do you have common functions to copy config file tree content to log file or should I create the list of file and copy content of each file to the logfile ?

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1336462/+subscriptions