Re: How to add a message to an issue via roundup-admin?
Dan Tenenbaum <[email protected]>
| Newsgroups | gmane.comp.bug-tracking.roundup.user |
|---|---|
| Message-ID | <[email protected]> |
----- Original Message ----- > From: "Dan Tenenbaum" <[email protected]> > To: "Ralf Schlatterbeck" <[email protected]> > Cc: [email protected] > Sent: Friday, June 12, 2015 11:38:39 AM > Subject: Re: [Roundup-users] How to add a message to an issue via roundup-admin? > > > > ----- Original Message ----- > > From: "Dan Tenenbaum" <[email protected]> > > To: "Ralf Schlatterbeck" <[email protected]> > > Cc: [email protected] > > Sent: Friday, June 12, 2015 8:15:59 AM > > Subject: Re: [Roundup-users] How to add a message to an issue via > > roundup-admin? > > > > > > > > ----- Original Message ----- > > > From: "Ralf Schlatterbeck" <[email protected]> > > > To: [email protected] > > > Sent: Friday, June 12, 2015 1:28:16 AM > > > Subject: Re: [Roundup-users] How to add a message to an issue via > > > roundup-admin? > > > > > > On Wed, Jun 10, 2015 at 03:11:18PM -0700, Dan Tenenbaum wrote: > > > > Hi, > > > > > > > > I'd like to be able to create a new message and add it to an > > > > issue > > > > via roundup-admin. > > > > > > > > I have issue1 and I was able to do this: > > > > > > > > $ roundup-admin -i . create msg > > > > Files (Multilink): > > > > Inreplyto (String): > > > > Recipients (Multilink): > > > > Author (Link): > > > > Summary (String): summary > > > > Content (String): content > > > > Messageid (String): > > > > Date (Date): > > > > Type (String): > > > > 5 > > > > > > This gets you the msg number 5 (the last number that is echoed). > > > > > > Then you can do the same with an issue: > > > $ roundup-admin -i . create issue > > > ... > > > Messages (Multilink): 5 > > > > > > When prompted for the "Messages" Multilink you enter the ID of > > > the > > > message just created. > > > > > > Alternatively if you want to append the message to an > > > already-existing > > > issue you first query the 'messages' of that issue, e.g., > > > > > > $ roundup-admin -i. get messages issue1 > > > ['3288', '25502', '32058', '41268', '100899', '366913'] > > > > > > And then append the message to it using set: > > > > > > $ roundup-admin -i. set issue1 > > > messages=5,3288,25502,32058,41268,100899,366913 > > > > > > > But I didn't see how to link the message to issue1. I did see a > > > > new > > > > entry in the _msg table but not in the issue_messages table. > > > > How > > > > do > > > > I > > > > do that? Do I need to create some other class that links the > > > > message > > > > to the issue? If so I'm not sure what that class is. Is there a > > > > way > > > > to > > > > list the available classes? Because then I could explore much > > > > more > > > > easily with 'roundup-admin list'. > > > > > > This is automagically done when you fill in the 'messages' > > > multilink > > > value in issue. > > > > > > > $ roundup-admin -i . display issue1|grep messages > > > > messages: ['1', '3', '4'] > > > > > > > > Then I can add to that: > > > > > > > > roundup-admin -i . set issue1 messages="1,3,4,5" > > > > > > > > But that seems awfully roundabout. I'd like to automate this. > > > > Is > > > > there > > > > a one-line command to create a message and add it to an issue? > > > > > > Yes, that's the way to do it (except that you can use 'get' > > > instead > > > of > > > 'display', see above). > > > > > > If you want a one-line command you can write a short script using > > > the > > > roundup API. > > > > I wasn't aware there was an API aside from the detectors/reactors > > API > > but in this case, detectors are not appropriate. > > Can you point me towards the documentation? Would it be something > > like this? > > > > http://www.roundup-tracker.org/cgi-bin/moin.cgi/DatabaseWrapper > > > > ? > > > > I guess you just mean writing a python script which imports the > > relevant roundup classes? > > OK, I've written such a script. The only problem is, it doesn't work! > The goal of it is to append a message to an existing issue. It does > that, such that when I then retrieve the issue's messages, it shows > me that it now has 2 messages whereas before it only had 1: > > In [92]: db.issue.get(1, 'messages') > Out[92]: ['1', '9'] > > However, when I look at issue1 in my browser it only shows one > message, and if I go to > > http://myhost.com/mytracker/msg9 > > it says there is no such message. But in the database I can see it: > > In [93]: db.getnode('msg', 9) > Out[93]: > {'activity': <Date 2015-06-12.18:28:39.000>, > 'actor': '1', > 'author': '3', > 'content': None, > 'creation': <Date 2015-06-12.18:27:39.000>, > 'creator': '1', > 'date': <Date 2015-06-12.18:27:39.000>, > 'files': [], > 'inreplyto': None, > 'messageid': '<[email protected]>', > 'recipients': ['1', '3'], > 'summary': 'hey\nho', > 'type': None} > > > So what is the script doing wrong? > One more clue: in my <tracker_home>/db/files/msg/0 directory there is not a msg9 file as I would expect but there is a msg9.tmp file with the correct contents. If I rename it to msg9 it does not fix the problem, the new message still does not show up attached to the issue. Thanks, Dan > Thanks in advance! Here's the script. > > Dan > > #!/usr/bin/env python > > import sys > from roundup import instance, hyperdb, date > from roundup.date import Date > > tracker_home = "/mytrackerhome" # conditionalize me! > instance = instance.open(tracker_home) > db = instance.open("admin") # make sure there is an admin user on > production! > > issue_id = 1 # parameterize me! > > try: > issue = db.getnode("issue", issue_id) > except IndexError: > print("No such issue!") > sys.exit(1) > > username = "admin" # parameterize me > > message = """ > hey > ho > """ # parameterize me > > matching_users = db.user.filter(None, {"username": username}) > > if len(matching_users) == 0: > print("No such user!") > sys.exit(1) > > userid = matching_users[0] > > msg_id = db.msg.create( > author=str(userid), > date=Date('.'), > summary=message, > content=message > ) > > messages = issue.get("messages") > > messages.append(msg_id) > > db.issue.set(str(issue_id), messages=messages) > > > > > > > BTW, what I want to do is append a message to an existing issue, > > not > > create a new issue and then append a message to it. > > > > Thanks for your help. > > > > Dan > > > > > An alternative is to prepare a full message in UNIX > > > mailbox > > > format and use roundup-mailgw to import it. In the subject you > > > would > > > have the issue in angular brackets to identify the issue, e.g. > > > > > > Subject: [issue1] New subject of this issue > > > > > > Ralf > > > -- > > > Dr. Ralf Schlatterbeck Tel: +43/2243/26465-16 > > > Open Source Consulting www: > > > http://www.runtux.com > > > Reichergasse 131, A-3411 Weidling email: [email protected] > > > allmenda.com member email: [email protected] > > > > > > ------------------------------------------------------------------------------ > > > _______________________________________________ > > > Roundup-users mailing list > > > [email protected] > > > https://lists.sourceforge.net/lists/listinfo/roundup-users > > > > > ------------------------------------------------------------------------------ > _______________________________________________ > Roundup-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/roundup-users > ------------------------------------------------------------------------------