SHARE
TWEET

Untitled

a guest Jun 26th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import subprocess
  2. package=input("insert package name:")
  3. t=subprocess.run(["apt-cache", "depends", "-i", package], stdout=subprocess.PIPE)
  4. if t.stderr or t.returncode:
  5.     print(t.stdout)
  6.     exit(t.stderr)
  7. #print(":", t.stdout)
  8. needed_pacages=t.stdout.split(b"Depends: ")
  9. print(package, "depends of", needed_pacages)
  10. for choices in needed_pacages:
  11.     one_choice_made=False
  12.     for needed_package in choices.split(b"n"):
  13.         needed_package=needed_package.strip(b"n ")
  14.         t=subprocess.run(["apt-get", "download", needed_package])
  15.         if t.stderr or t.returncode:
  16.             print("ERROR: Status: {p.returncode}, stdout: {p.stdout}, stderr: {p.stderr}".format(p=t), "package name:", needed_package)
  17.         else:
  18.             one_choice_made = True
  19.             #print("downloaded",vajalik_pakk)
  20.             break
  21.     if not one_choice_made:
  22.         print("could not get one of dependecies", choices)
  23.      
  24. def r(pakk):
  25.     t=subprocess.run(["apt-get", "download", pakk])
  26.     if t.stderr or t.returncode:
  27.         #print("could not load package: Status: {p.returncode}, stdout: {p.stdout}, stderr: {p.stderr}".format(p=t), "paki nimi:", pakk)
  28.         return False
  29.     olemas_olevad_pakid.add(pakk)
  30.     t=subprocess.run(["apt-cache", "depends", "-i", pakk], stdout=subprocess.PIPE)
  31.     if t.stderr or t.returncode:
  32.         print(t.stdout)
  33.         exit(t.stderr)
  34.     #print(":", t.stdout)
  35.     needed_pacages=t.stdout.split(b"Depends: ")[1:]
  36.     #print(pakk, "needs packages:", needed_pacages)
  37.     for choices in needed_pacages:
  38.         one_choice_made=False
  39.         for needed_package in choices.split(b"n"):
  40.             needed_package=needed_package.strip(b"n ")
  41.             if needed_package in olemas_olevad_pakid or r(needed_package):
  42.                 one_choice_made=True
  43.                 break
  44.         if not one_choice_made:
  45.             print("PROBLEM: could not download any of", choices)
  46.             return False
  47.     return True
  48. #for pakk in packages_to_download:
  49. #    print("pakk:",pakk)
  50. #    r(pakk)
  51. r(input("package name:"))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top