Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.48 KB | None | 0 0
  1. def rpm_subs_hash(path):
  2.         """ Get actual subsystems of correction rpm file.
  3.                Returns dictionary of subsystems with their revisions.
  4.                Takes values from current rpm file.
  5.        """
  6. #               rpm -qlp returns path in following format
  7. #               /var/mnt/local/sysimg/flexiserver/opt/Nokia/var/swmgmt/downloaded_rpms/R_GOMS6_1.19.1.0.release_oms.corr76
  8. #               /var/mnt/local/sysimg/flexiserver/opt/Nokia/var/swmgmt/downloaded_rpms/R_GOMS6_1.19.1.0.release_oms.corr76/SS_Affe-1.37415-R_GOMS6_1.19.1.0_corr76.x86_64.rpm
  9. #               Script needs to ignore lines not containing .rpm files, then remove path (os.split()) and then split actual rpm file.
  10. #               SS_Affe-1.37415-R_GOMS6_1.19.1.0_corr76.x86_64.rpm:
  11. #               (SS_Affe)-1.(37415)-R_GOMS6_1.19.1.0_corr76.x86_64.rpm.
  12. #               This will return a dictionary where first bracket captures a key (name of subsystem) and second captures value (revision of subsystem).
  13.         print("rpm_subs_hash: path: %s") % path
  14.  
  15.         hashtable = {}
  16.         r = re.compile(r'(SS_[A-Za-z]+)-([\d\.]+).*\.rpm$')
  17.  
  18.         ret = subprocess.Popen("/bin/rpm -qlp %s" % path, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  19.         for filepath in ret.stdout.lines():
  20.                 match = r.search(filepath)
  21.                 if match:
  22.                         hashtable.update(dict(match.groups()))
  23.         return hashtable
  24.  
  25. ----------------------
  26.  
  27. ./check_rpm.py -r R_GOMS6_1.19.1.0 -c 80
  28. Starting main
  29. Parsing options
  30. get_arch: SELECT Platform from products_table WHERE RIS='R_GOMS6_1.19.1.0' LIMIT 1;
  31. get_arch: arch: both
  32. get_mode: SELECT is_release from products_table WHERE RIS='R_GOMS6_1.19.1.0';
  33. main: corr_arch: both, corr_mode: release
  34. main: corr_path64: /build/OMS/R_GOMS6_1.19.1.0.release/corr80/R_GOMS6_1.19.1.0.release_oms.corr80-inc-1.rpm
  35. rpm_subs_hash: path: /build/OMS/R_GOMS6_1.19.1.0.release/corr80/R_GOMS6_1.19.1.0.release_oms.corr80-inc-1.rpm
  36. Traceback (most recent call last):
  37.   File "./check_rpm.py", line 162, in ?
  38.     main()
  39.   File "./check_rpm.py", line 137, in main
  40.     rpmsubs_hash64 = rpm_subs_hash(corr_path64)
  41.   File "./check_rpm.py", line 50, in rpm_subs_hash
  42.     ret = subprocess.Popen("/bin/rpm -qlp" +path)
  43.   File "/usr/lib64/python2.4/subprocess.py", line 550, in __init__
  44.     errread, errwrite)
  45.   File "/usr/lib64/python2.4/subprocess.py", line 993, in _execute_child
  46.     raise child_exception
  47. OSError: [Errno 2] No such file or directory
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement