|
|
@ -18,33 +18,56 @@ GNU General Public License for more details.
|
|
|
|
A copy of the GNU General Public License version 2 is in license.txt.
|
|
|
|
A copy of the GNU General Public License version 2 is in license.txt.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import apt
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import launchpadlib
|
|
|
|
import launchpadlib
|
|
|
|
from launchpadlib.launchpad import Launchpad
|
|
|
|
from launchpadlib.launchpad import Launchpad
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
|
|
|
|
parser.add_argument("-f", "--file", help="The path of the input file", required=True)
|
|
|
|
|
|
|
|
parser.add_argument("-u", "--lp-user", help="The Launchpad ID of the team you would like to subscribe the bugs to", required=True)
|
|
|
|
|
|
|
|
parser.add_argument("-r", "--remove", action="store_true", help="Instead of subscribing to the packages, unsubscribe")
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
def no_credential():
|
|
|
|
def no_credential():
|
|
|
|
print("Can't proceed without Launchpad credentials.")
|
|
|
|
raise ValueError("Can't proceed without Launchpad credentials.")
|
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lp = Launchpad.login_with('Mass package bug subscription adder', 'production', credential_save_failed=no_credential)
|
|
|
|
lp = Launchpad.login_with("masspackagelp", "production", credential_save_failed=no_credential)
|
|
|
|
teamtowrite = (input('What person/team would you like to use for this? (Launchpad ID) '))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
def main():
|
|
|
|
try:
|
|
|
|
while True:
|
|
|
|
filepath = (input('Please specify the path of the input file: '))
|
|
|
|
try:
|
|
|
|
with open(filepath, "r") as ins:
|
|
|
|
with open(args.file, "r") as ins:
|
|
|
|
filearray = []
|
|
|
|
filelines = []
|
|
|
|
for line in ins:
|
|
|
|
for line in ins:
|
|
|
|
filearray.append(line.strip())
|
|
|
|
filelines.append(line.strip())
|
|
|
|
break
|
|
|
|
break
|
|
|
|
except FileNotFoundError:
|
|
|
|
except FileNotFoundError:
|
|
|
|
print("File not found.")
|
|
|
|
raise FileNotFoundError("File not found.")
|
|
|
|
|
|
|
|
|
|
|
|
for i in range(len(filearray)):
|
|
|
|
if not args.remove:
|
|
|
|
print("Assigning:")
|
|
|
|
for i in range(len(filelines)):
|
|
|
|
print(filearray[i])
|
|
|
|
try:
|
|
|
|
|
|
|
|
lp.distributions["ubuntu"].getSourcePackage(name=filelines[i]).addBugSubscription(subscriber=lp.people[args.lp_user])
|
|
|
|
|
|
|
|
print("Successfully added subscription for " + filelines[i])
|
|
|
|
|
|
|
|
except AttributeError:
|
|
|
|
|
|
|
|
print("Source package " + filelines[i] + " not found")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
for i in range(len(filelines)):
|
|
|
|
|
|
|
|
print("Removing subscription for: " + filelines[i])
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
lp.distributions["ubuntu"].getSourcePackage(name=filelines[i]).removeBugSubscription(subscriber=lp.people[args.lp_user])
|
|
|
|
|
|
|
|
print("Successfully removed subscription for " + filelines[i])
|
|
|
|
|
|
|
|
except AttributeError:
|
|
|
|
|
|
|
|
print("Source package not found.")
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
print(args.lp_user + " is not subscribed to " + filelines[i] + " so not removing")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
lp.distributions['ubuntu'].getSourcePackage(name=filearray[i]).addBugSubscription(subscriber=lp.people[teamtowrite])
|
|
|
|
main()
|
|
|
|
except AttributeError:
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
print("Source package not found.")
|
|
|
|
print("Exiting...")
|
|
|
|
print("Complete")
|
|
|
|
exit()
|
|
|
|