unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* Re: Next steps
       [not found]                                         ` <87r2l767sg.fsf@elephly.net>
@ 2018-06-24 18:25                                           ` Sahithi Yarlagadda
  2018-06-24 20:22                                             ` Ricardo Wurmus
  0 siblings, 1 reply; 3+ messages in thread
From: Sahithi Yarlagadda @ 2018-06-24 18:25 UTC (permalink / raw)
  To: Ricardo Wurmus, help-guix; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 319 bytes --]

Hi all,

The following are the changes that I made earlier.... and changes worked
fine...

This patch is pushed to my branch wip-sahithi

But when I try executing it now I don't find its results.... not even
soft-port is getting called...

May I know the reason behind this....


---
Thanks!!
Sahithi


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-guix-Add-coloring-soft-port.patch --]
[-- Type: text/x-patch; name="0001-guix-Add-coloring-soft-port.patch", Size: 3905 bytes --]

From 99526f5624633e5fdc72fe8fb280b1279bea0636 Mon Sep 17 00:00:00 2001
From: Sahithi Yarlagadda <sahi@swecha.net>
Date: Sat, 16 Jun 2018 13:21:42 +0530
Subject: [PATCH] guix: Add coloring soft port.

* guix/ui.scm (handle-string): New procedures.
(colorful-build-output-port): New variable.

guix: Added colorful-build-output-port to build.scm instead of default
---
 guix/scripts/build.scm |  4 +---
 guix/ui.scm            | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index 4dd4fbccd..81ad255d8 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -733,9 +733,7 @@ needed."
         ;; Set the build options before we do anything else.
         (set-build-options-from-command-line store opts)
 
-        (parameterize ((current-build-output-port (if quiet?
-                                                      (%make-void-port "w")
-                                                      (current-error-port))))
+         (parameterize ((current-build-output-port  colorful-build-output-port))
           (let* ((mode  (assoc-ref opts 'build-mode))
                  (drv   (options->derivations store opts))
                  (urls  (map (cut string-append <> "/log")
diff --git a/guix/ui.scm b/guix/ui.scm
index 80f1a4d77..88e5fa6b7 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -109,7 +109,7 @@
             warning
             info
             guix-main
-            colorize-string))
+            colorful-build-output-port))
 
 ;;; Commentary:
 ;;;
@@ -1631,4 +1631,51 @@ be reset such that subsequent output will not have any colors in effect."
    str
    (color 'RESET)))
 
+(define (handle-string str)
+ "Accepts input string(str) as argument and checks whether it matches with one 
+of the regular expressions specified. Upon matching, each substring is colorized 
+with corresponding colors and the modified colored string is returned. If the 
+input string fails match with the following conditionals it returns back the 
+unmodified input string."
+    (let ((message  (or (and=> (string-match "^(starting phase)(.*)" str)
+           (lambda (m)
+             (string-append
+               (colorize-string (match:substring m 1) 'BLUE)
+               (colorize-string (match:substring m 2) 'GREEN))))
+
+       (and=> (string-match "^(phase)(.*)(succeeded after)(.*)(seconds)" str)
+          (lambda (m)
+            (string-append
+              (colorize-string (match:substring m 1) 'BLUE)
+              (colorize-string (match:substring m 2) 'GREEN)
+              (colorize-string (match:substring m 3) 'BLUE)
+              (colorize-string (match:substring m 4) 'GREEN)
+              (colorize-string (match:substring m 5) 'BLUE))))
+
+       (and=> (string-match "^(phase)(.*)(failed after)(.*)(seconds)" str)
+          (lambda (m)
+            (string-append
+              (colorize-string (match:substring m 1) 'RED)
+              (colorize-string (match:substring m 2) 'GREEN)
+              (colorize-string (match:substring m 3) 'RED)
+              (colorize-string (match:substring m 4) 'GREEN)
+              (colorize-string (match:substring m 5) 'RED))))
+
+     ;; Didn’t match with any expression, returns back unmodified string.
+       str)))
+    (display message (current-error-port))))
+
+(define colorful-build-output-port
+  (make-soft-port
+   (vector
+     ;; procedure accepting one character for output
+    (lambda (c) (write c (current-error-port)))
+     ;; procedure accepting a string for handle-string procedure
+    handle-string
+    (lambda () (force-output (current-error-port)))
+    (const #t)
+    (lambda () (display "@" (current-error-port))))
+   "rw"))
+
+
 ;;; ui.scm ends here
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: Next steps
  2018-06-24 18:25                                           ` Next steps Sahithi Yarlagadda
@ 2018-06-24 20:22                                             ` Ricardo Wurmus
  2018-06-24 20:33                                               ` Sahithi Yarlagadda
  0 siblings, 1 reply; 3+ messages in thread
From: Ricardo Wurmus @ 2018-06-24 20:22 UTC (permalink / raw)
  To: Sahithi Yarlagadda; +Cc: guix-devel, help-guix


Hi Sahithi,

I checked out the “wip-sahithi” branch and ran this command in a
terminal (urxvt):

    ./pre-inst-env guix build --check --no-grafts hello

I do see colours for phase start and end notices, so the code is fine.

What terminal are you using?  Did this not work for you before?  What
has changed since?

--
Ricardo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Next steps
  2018-06-24 20:22                                             ` Ricardo Wurmus
@ 2018-06-24 20:33                                               ` Sahithi Yarlagadda
  0 siblings, 0 replies; 3+ messages in thread
From: Sahithi Yarlagadda @ 2018-06-24 20:33 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel, help-guix

Hi


On Monday 25 June 2018 01:52 AM, Ricardo Wurmus wrote:
> Hi Sahithi,
>
> I checked out the “wip-sahithi” branch and ran this command in a
> terminal (urxvt):
>
>     ./pre-inst-env guix build --check --no-grafts hello
>
> I do see colours for phase start and end notices, so the code is fine.
It worked for me now, when i tested it by checking out to wip-sahithi
branch.
> What terminal are you using?  Did this not work for you before?  What
> has changed since?
Gnome terminal
It worked for me earlier as well, i tested the code by building the
hello package before sending the patch.

Unsure why it dint work, i did couple of changes and reverted back
thought. Seems i missed something out.
>
> --
> Ricardo
>
>

-- 
Regards
Sahithi

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-24 20:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <8ea5d026-fab9-7b12-198e-610ad7743cb2@swecha.net>
     [not found] ` <87fu1zznl3.fsf@elephly.net>
     [not found]   ` <f76f5ced-df02-fdcd-0a7a-37565d5d8605@swecha.net>
     [not found]     ` <87bmcnzjsp.fsf@elephly.net>
     [not found]       ` <18408eca-ad0b-111a-0ef6-ab452c9ca89c@swecha.net>
     [not found]         ` <878t7ryxvf.fsf@elephly.net>
     [not found]           ` <02e1a59a-ebc1-dfce-e1d6-22e97e742214@swecha.net>
     [not found]             ` <874lifypeb.fsf@elephly.net>
     [not found]               ` <648f81fc-0607-2c3b-f9a3-ca3b29cd637b@swecha.net>
     [not found]                 ` <87bmck22uz.fsf@elephly.net>
     [not found]                   ` <c2401637-c975-d416-e3a2-7b1535924c61@swecha.net>
     [not found]                     ` <8736xv1xvq.fsf@elephly.net>
     [not found]                       ` <64dfaf0c-3bcf-7b76-5831-b1c41d3f5563@swecha.net>
     [not found]                         ` <CAE4v=pjiR2fVN3SoA+NqSt4T9VEvM9Gfsz9OUPW=7X9RnNE7mg@mail.gmail.com>
     [not found]                           ` <c1a084e9-b888-1d01-b1fe-3e423169e750@swecha.net>
     [not found]                             ` <877en4ccut.fsf@elephly.net>
     [not found]                               ` <2b03fcec-c2d8-0604-156c-70fe7643a6cb@swecha.net>
     [not found]                                 ` <87zhzzbqn6.fsf@elephly.net>
     [not found]                                   ` <8f509759-c798-a150-bf5a-9b13cd07ac5b@swecha.net>
     [not found]                                     ` <87lgbibir5.fsf@elephly.net>
     [not found]                                       ` <564233bd-9511-7f84-3350-6a3a905534a8@swecha.net>
     [not found]                                         ` <87r2l767sg.fsf@elephly.net>
2018-06-24 18:25                                           ` Next steps Sahithi Yarlagadda
2018-06-24 20:22                                             ` Ricardo Wurmus
2018-06-24 20:33                                               ` Sahithi Yarlagadda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).