Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.74 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.         p = re.compile('SS_[A-Za-z]+')
  16.         t = re.compile('-1\.\d+')
  17.  
  18.         ret = subprocess.Popen("/bin/rpm -qlp %s" % path, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  19.         for filepath in ret.stdout.lines():
  20.                 if(filepath.find("rpm")):
  21.                         rpmfile = os.path.basename(filepath)
  22.                         sub = p.match(rpmfile)
  23.                         tempr = t.match(rpmfile)
  24.                         temprev = tempr.group()
  25.                         (temp, rev) = temprev.split(".")
  26.                         hashtable = {sub: rev}
  27.                 else:
  28.                         continue
  29.         return hashtable
  30.  
  31. ----------------------
  32.  
  33. ./check_rpm.py -r R_GOMS6_1.19.1.0 -c 80
  34. Starting main
  35. Parsing options
  36. get_arch: SELECT Platform from products_table WHERE RIS='R_GOMS6_1.19.1.0' LIMIT 1;
  37. get_arch: arch: both
  38. get_mode: SELECT is_release from products_table WHERE RIS='R_GOMS6_1.19.1.0';
  39. main: corr_arch: both, corr_mode: release
  40. 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
  41. 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
  42. Traceback (most recent call last):
  43.   File "./check_rpm.py", line 162, in ?
  44.     main()
  45.   File "./check_rpm.py", line 137, in main
  46.     rpmsubs_hash64 = rpm_subs_hash(corr_path64)
  47.   File "./check_rpm.py", line 50, in rpm_subs_hash
  48.     ret = subprocess.Popen("/bin/rpm -qlp" +path)
  49.   File "/usr/lib64/python2.4/subprocess.py", line 550, in __init__
  50.     errread, errwrite)
  51.   File "/usr/lib64/python2.4/subprocess.py", line 993, in _execute_child
  52.     raise child_exception
  53. OSError: [Errno 2] No such file or directory
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement