[prev in list] [next in list] [prev in thread] [next in thread] 

List:       fedora-buildsys-list
Subject:    Possible Code Changes For Tickets #41 #76
From:       Jon Chiappetta <jon.chiappetta () senecac ! on ! ca>
Date:       2011-12-03 22:15:08
Message-ID: fbb285778735.4eda591c () senecac ! on ! ca
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


In terms of adding "tail-like" functionality to Koji "watch-logs" sub-command: 


https://fedorahosted.org/koji/ticket/41
https://fedorahosted.org/koji/ticket/76



$ ./koji-1.6.0/cli/koji watch-logs 3559606 --log=build.log --tail=10
Watching logs (this may be safely interrupted)...
Wrote: /builddir/build/RPMS/calibre-0.8.29-1.fc15.i686.rpm
Wrote: /builddir/build/RPMS/calibre-debuginfo-0.8.29-1.fc15.i686.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.RypJxm
+ umask 022
+ cd /builddir/build/BUILD
+ cd calibre
+ /bin/rm -rf /builddir/build/BUILDROOT/calibre-0.8.29-1.fc15.i386
+ exit 0
Child returncode was: 0
LEAVE do --> 




$ diff -u /usr/bin/koji ./koji-1.6.0/cli/koji
--- /usr/bin/koji	2010-12-16 16:13:17.000000000 -0500
+++ ./koji-1.6.0/cli/koji	2011-12-03 17:09:42.225650495 -0500
@@ -433,6 +433,7 @@
             offsets[task_id] = {}
 
         lastlog = None
+        logline = ""
         while True:
             for task_id in tasklist[:]:
                 if _isDone(session, task_id):
@@ -458,15 +459,28 @@
                             currlog = "%d:%s:" % (task_id, log)
                             if currlog != lastlog:
                                 if lastlog:
-                                    sys.stdout.write("\n")
-                                sys.stdout.write("==> %s <==\n" % currlog)
+                                    logline += ("\n")
+                                logline += ("==> %s <==\n" % currlog)
                                 lastlog = currlog
-                            sys.stdout.write(contents)
+                            logline += (contents)
 
             if not tasklist:
                 break
 
             time.sleep(options.poll_interval)
+        
+        loglist = logline.strip("\n").split("\n")
+        endline = len(loglist)
+        try:
+            subvalue = int(opts.tail)
+        except:
+            subvalue = endline
+        if (subvalue > endline):
+            subvalue = endline
+        begline = (endline - subvalue)
+        for x in range(begline, endline):
+            print(loglist[x])
+        
     except (KeyboardInterrupt):
         pass
 
@@ -5083,6 +5097,7 @@
     usage += _("\n(Specify the --help global option for a list of other help options)")
     parser = OptionParser(usage=usage)
     parser.add_option("--log", help=_("Watch only a specific log"))
+    parser.add_option("--tail", help=_("Watch only the last N lines"))
     (options, args) = parser.parse_args(args)
     activate_session(session)
 



[Attachment #5 (text/html)]

In terms of adding "tail-like" functionality to Koji "watch-logs" \
sub-command:&nbsp;<br><br><br>https://fedorahosted.org/koji/ticket/41<br>https://fedorahosted.org/koji/ticket/76<br><br><br><br>$ \
./koji-1.6.0/cli/koji watch-logs 3559606 --log=build.log --tail=10<br>Watching logs \
(this may be safely interrupted)...<br>Wrote: \
/builddir/build/RPMS/calibre-0.8.29-1.fc15.i686.rpm<br>Wrote: \
/builddir/build/RPMS/calibre-debuginfo-0.8.29-1.fc15.i686.rpm<br>Executing(%clean): \
/bin/sh -e /var/tmp/rpm-tmp.RypJxm<br>+ umask 022<br>+ cd /builddir/build/BUILD<br>+ \
cd calibre<br>+ /bin/rm -rf /builddir/build/BUILDROOT/calibre-0.8.29-1.fc15.i386<br>+ \
exit 0<br>Child returncode was: 0<br>LEAVE do --&gt;&nbsp;<br><br><br><br><br>$ diff \
-u /usr/bin/koji ./koji-1.6.0/cli/koji<br>--- /usr/bin/koji<span \
class="Apple-tab-span" style="white-space:pre">	</span>2010-12-16 16:13:17.000000000 \
-0500<br>+++ ./koji-1.6.0/cli/koji<span class="Apple-tab-span" \
style="white-space:pre">	</span>2011-12-03 17:09:42.225650495 -0500<br>@@ -433,6 \
+433,7 @@<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;offsets[task_id] = \
{}<br>&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lastlog = None<br>+ &nbsp; &nbsp; \
&nbsp; &nbsp;logline = ""<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;while True:<br>&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for task_id in tasklist[:]:<br>&nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if _isDone(session, task_id):<br>@@ \
-458,15 +459,28 @@<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;currlog = "%d:%s:" % (task_id, \
log)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp;if currlog != lastlog:<br>&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;if lastlog:<br>- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;sys.stdout.write("\n")<br>- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;sys.stdout.write("==&gt; %s &lt;==\n" % currlog)<br>+ &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp;logline += ("\n")<br>+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;logline += \
("==&gt; %s &lt;==\n" % currlog)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lastlog = \
currlog<br>- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp;sys.stdout.write(contents)<br>+ &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;logline \
+= (contents)<br>&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if not \
tasklist:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;break<br>&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;time.sleep(options.poll_interval)<br>+ &nbsp; &nbsp; &nbsp; &nbsp;<br>+ &nbsp; \
&nbsp; &nbsp; &nbsp;loglist = logline.strip("\n").split("\n")<br>+ &nbsp; &nbsp; \
&nbsp; &nbsp;endline = len(loglist)<br>+ &nbsp; &nbsp; &nbsp; &nbsp;try:<br>+ &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;subvalue = int(opts.tail)<br>+ &nbsp; &nbsp; &nbsp; \
&nbsp;except:<br>+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;subvalue = endline<br>+ \
&nbsp; &nbsp; &nbsp; &nbsp;if (subvalue &gt; endline):<br>+ &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp;subvalue = endline<br>+ &nbsp; &nbsp; &nbsp; &nbsp;begline = \
(endline - subvalue)<br>+ &nbsp; &nbsp; &nbsp; &nbsp;for x in range(begline, \
endline):<br>+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;print(loglist[x])<br>+ &nbsp; \
&nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp;except (KeyboardInterrupt):<br>&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp;pass<br>&nbsp;<br>@@ -5083,6 +5097,7 @@<br>&nbsp; &nbsp; \
&nbsp;usage += _("\n(Specify the --help global option for a list of other help \
options)")<br>&nbsp; &nbsp; &nbsp;parser = OptionParser(usage=usage)<br>&nbsp; &nbsp; \
&nbsp;parser.add_option("--log", help=_("Watch only a specific log"))<br>+ &nbsp; \
&nbsp;parser.add_option("--tail", help=_("Watch only the last N lines"))<br>&nbsp; \
&nbsp; &nbsp;(options, args) = parser.parse_args(args)<br>&nbsp; &nbsp; \
&nbsp;activate_session(session)<br>&nbsp;<br>


[Attachment #6 (text/plain)]

--
buildsys mailing list
buildsys@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/buildsys

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic