Re: Status of Submitted Patches

2018-05-15 Thread Sahitihi
Hi Ricardo,

> Here you are reading a character from the current input port.  The
> result is fed to “char-upcase”, which turns it into an upper-case
> variant, and then you write that character to the current default output
> port.
>
> While this achieves the goal for a single character it does not
> constitute a custom port.  Have you read the documentation for
> “make-custom-port” in the Guile manual?

I have tried with the following code for, Gábor helped me in process

(use-modules (ice-9 binary-ports))
(use-modules (ice-9 i18n))

(define stdout (current-output-port))
(define s (read(current-input-port)))
(define p (make-soft-port
   (vector
    (lambda (c) (write c stdout))
    (lambda (s) (display (string-upcase! s) stdout))
    (lambda () (display "." stdout))
    (lambda () (char-upcase (read-char)))
    (lambda () (display "@" stdout)))
   "rw"))
(write s p)

The above resulted me with a capitalized output
> What type is the value in the variable with name “a”?  “read-char” takes
> a port and returns a single character from it, “char-upcase” takes a
> character and returns a different character, so “a” holds a character.
> As you know, the implementation of “colorize-string” internally glues a
> bunch of strings together: a terminal escape sequence to set the colour,
> the string to be coloured, and a terminal escape sequence to disable the
> colour.  You gave a character to the procedure, but it expects a string.
>
(use-modules (ice-9 binary-ports)) ;Though name is binary, All ports in
Guile are both binary and textual ports.
(use-modules (ice-9 i18n))  ; The |(ice-9 i18n)| module provides
procedures to manipulate text and other data
(use-modules (ice-9 colorized)) ;Colorizing module
(activate-colorized)

(define stdout (current-output-port)) ;stdout variable act as an output port
(define s (read(current-input-port))) ; s variable reads the input from
input port
;soft ports are used for customization on how output port works
(define p (make-soft-port
   (vector
    (lambda (c) (write c stdout)) ;accepting one character for
output
    (lambda (s) (display (colorized-display (string-upcase! s)
'(GREEN)) stdout)) ;accepting a string, Capitalizing it and then
colorizing with for output
    (lambda () (display "." stdout))
    (lambda () (char-upcase (read-char)))
    (lambda () (display "@" stdout)))
   "rw"))
(write s p)



This results out with a capitalized, colorized output

the description for that goes this way

The input taken from input port is read and stored in variable "s". 
This variable is passed to make-soft-port.  The variable s is
capitalized by locale conversion then binded with color. the result is
displayed when called.


I have tried the other process using escape codes however failed with
the result i will come with this implementation and procedure in my next
mail



Re: Status of Submitted Patches

2018-05-23 Thread Sahitihi

Hi Ricardo,
> As a first change, could you please add the relevant parts of “(ice-9
> colorized)” to a module in Guix?  We probably don’t want to depend on
> having users install this module separately.  We also don’t need all of
> it.  Please prepare a patch that adds only the relevant parts to “(guix
> ui)” and update the copyright headers.

I think small changes to the attached file will serve the purpose.
But when I tried executing the file, that resulted with a error unbound 
variable : colorize string 

I am not sure where I went wrong, can you please explain.

--Sahithi

(display (colorize-string "Hello!\n" 'RED 'BOLD 'ON-BLUE))

(for-each display
  (list (color 'RED 'BOLD 'ON-BLUE)
"Hello!"
 (color 'RESET)))
(define-module (term ansi-color)
 #:export  (color
colorize-string)
 #:use-module (srfi srfi-1)   ; for 'remove'
 #:use-module (srfi srfi-13)) ; for 'string-join' 

(define ansi-color-tables
  (let ((table (make-hash-table 23)))
(hashq-set! table 'CLEAR "0")
(hashq-set! table 'RESET "0")
(hashq-set! table 'BOLD  "1")
(hashq-set! table 'DARK  "2")
(hashq-set! table 'UNDERLINE "4")
(hashq-set! table 'UNDERSCORE "4")
(hashq-set! table 'BLINK "5")
(hashq-set! table 'REVERSE "6")
(hashq-set! table 'CONCEALED "8")
(hashq-set! table 'BLACK "30")
(hashq-set! table 'RED "31")
(hashq-set! table 'GREEN "32")
(hashq-set! table 'YELLOW "33")
(hashq-set! table 'BLUE "34")
(hashq-set! table 'MAGENTA "35")
(hashq-set! table 'CYAN "36")
(hashq-set! table 'WHITE "37")
(hashq-set! table 'ON-BLACK "40")
(hashq-set! table 'ON-RED "41")
(hashq-set! table 'ON-GREEN "42")
(hashq-set! table 'ON-YELLOW "43")
(hashq-set! table 'ON-BLUE "44")
(hashq-set! table 'ON-MAGENTA "45")
(hashq-set! table 'ON-CYAN "46")
(hashq-set! table 'ON-WHITE "47")
table))

(define (color . lst)
  (let ((color-list 
 (remove not 
 (map (lambda (color) (hashq-ref ansi-color-tables color))
  lst
(if (null? color-list)
""
(string-append 
 (string #\esc #\[)
 (string-join color-list ";" 'infix)
 "m"
  
(define (colorize-string str . color-list)
  (string-append
   (apply color color-list)
   str
   (color 'RESET)))



Patch file for colorize module

2018-05-25 Thread Sahitihi
Hi Ricardo,

Please find the attachment..

> Please attach the file of that same name in an email.
Also add any corrections that i need too and next steps to proceed
further. :)


Thanks!
--
Sahithi
>From 93f3c964250587d6272065d555fa07e9bdd47325 Mon Sep 17 00:00:00 2001
From: root 
Date: Fri, 25 May 2018 23:23:57 +0530
Subject: [PATCH] Added colorize module to ui.scm

---
 guix/ui.scm | 53 +++--
 1 file changed, 51 insertions(+), 2 deletions(-)

diff --git a/guix/ui.scm b/guix/ui.scm
index 8d351607d..e7c5d2972 100755
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -9,7 +9,9 @@
 ;;; Copyright © 2015, 2016 Mathieu Lirzin 
 ;;; Copyright © 2016 Roel Janssen 
 ;;; Copyright © 2016 Benz Schenk 
-;;;
+;;; Copyright © 2013,2014 Free Software Foundation, Inc.
+;;; Copyright © 2016 Sahithi Yarlagadda 
+;;; 
 ;;; This file is part of GNU Guix.
 ;;;
 ;;; GNU Guix is free software; you can redistribute it and/or modify it
@@ -106,7 +108,9 @@
 guix-warning-port
 warning
 info
-guix-main))
+guix-main
+color
+colorize-string))
 
 ;;; Commentary:
 ;;;
@@ -1578,4 +1582,49 @@ and signal handling has already been set up."
   (initialize-guix)
   (apply run-guix args))
 
+(define ansi-color-tables
+  `((CLEAR   .   "0")
+(RESET   .   "0")
+(BOLD.   "1")
+(DARK.   "2")
+(UNDERLINE   .   "4")
+(UNDERSCORE  .   "4")
+(BLINK   .   "5")
+(REVERSE .   "6")
+(CONCEALED   .   "8")
+(BLACK   .  "30")
+(RED .  "31")
+(GREEN   .  "32")
+(YELLOW  .  "33")
+(BLUE.  "34")
+(MAGENTA .  "35")
+(CYAN.  "36")
+(WHITE   .  "37")
+(ON-BLACK.  "40")
+(ON-RED  .  "41")
+(ON-GREEN.  "42")
+(ON-YELLOW   .  "43")
+(ON-BLUE .  "44")
+(ON-MAGENTA  .  "45")
+(ON-CYAN .  "46")
+(ON-WHITE.  "47")))
+
+(define (color . lst)
+  (let ((color-list 
+ (remove not 
+ (map (lambda (color) (assq-ref ansi-color-tables color))
+  lst
+(if (null? color-list)
+""
+(string-append 
+ (string #\esc #\[)
+ (string-join color-list ";" 'infix)
+ "m"
+  
+(define (colorize-string str . color-list)
+  (string-append
+   (apply color color-list)
+   str
+   (color 'RESET)))
+
 ;;; ui.scm ends here
-- 
2.11.0



Re: Patch file for colorize module

2018-05-26 Thread Sahitihi
Sorry,

Please find patch file attached to this mail. Kindly ignore the previous
one.

I have made a small change to Copyrights line to that of previous.
> Hi Ricardo,
>
> Please find the attachment..
>
>> Please attach the file of that same name in an email.
> Also add any corrections that i need too and next steps to proceed
> further. :)

Thanks!
--
Sahithi

>From 2cb775a4a8ea3337c7478145ccafffd1fe435df6 Mon Sep 17 00:00:00 2001
From: root 
Date: Sat, 26 May 2018 11:32:25 +0530
Subject: [PATCH 2/2] Added Colorize module and Copyrights line to ui.scm

---
 guix/ui.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/guix/ui.scm b/guix/ui.scm
index e7c5d2972..20fbf761f 100755
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -10,7 +10,7 @@
 ;;; Copyright © 2016 Roel Janssen 
 ;;; Copyright © 2016 Benz Schenk 
 ;;; Copyright © 2013,2014 Free Software Foundation, Inc.
-;;; Copyright © 2016 Sahithi Yarlagadda 
+;;; Copyright © 2018 Sahithi Yarlagadda 
 ;;; 
 ;;; This file is part of GNU Guix.
 ;;;
-- 
2.11.0



Re: Patch file for colorize module

2018-05-26 Thread Sahitihi
Hi Ricardo,

Please find the attachment. Hope I made it correct this time. :)


On Saturday 26 May 2018 03:05 PM, Ricardo Wurmus wrote:
> git rebase -i
> $start_commit

>From 1bd9eaca576e7d958062197b9931d64c0882484e Mon Sep 17 00:00:00 2001
From: root 
Date: Sat, 26 May 2018 17:34:23 +0530
Subject: [PATCH] Added Colorize module and Copyrights line to ui

---
 guix/ui.scm | 53 +++--
 1 file changed, 51 insertions(+), 2 deletions(-)

diff --git a/guix/ui.scm b/guix/ui.scm
index 8d351607d..20fbf761f 100755
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -9,7 +9,9 @@
 ;;; Copyright © 2015, 2016 Mathieu Lirzin 
 ;;; Copyright © 2016 Roel Janssen 
 ;;; Copyright © 2016 Benz Schenk 
-;;;
+;;; Copyright © 2013,2014 Free Software Foundation, Inc.
+;;; Copyright © 2018 Sahithi Yarlagadda 
+;;; 
 ;;; This file is part of GNU Guix.
 ;;;
 ;;; GNU Guix is free software; you can redistribute it and/or modify it
@@ -106,7 +108,9 @@
 guix-warning-port
 warning
 info
-guix-main))
+guix-main
+color
+colorize-string))
 
 ;;; Commentary:
 ;;;
@@ -1578,4 +1582,49 @@ and signal handling has already been set up."
   (initialize-guix)
   (apply run-guix args))
 
+(define ansi-color-tables
+  `((CLEAR   .   "0")
+(RESET   .   "0")
+(BOLD.   "1")
+(DARK.   "2")
+(UNDERLINE   .   "4")
+(UNDERSCORE  .   "4")
+(BLINK   .   "5")
+(REVERSE .   "6")
+(CONCEALED   .   "8")
+(BLACK   .  "30")
+(RED .  "31")
+(GREEN   .  "32")
+(YELLOW  .  "33")
+(BLUE.  "34")
+(MAGENTA .  "35")
+(CYAN.  "36")
+(WHITE   .  "37")
+(ON-BLACK.  "40")
+(ON-RED  .  "41")
+(ON-GREEN.  "42")
+(ON-YELLOW   .  "43")
+(ON-BLUE .  "44")
+(ON-MAGENTA  .  "45")
+(ON-CYAN .  "46")
+(ON-WHITE.  "47")))
+
+(define (color . lst)
+  (let ((color-list 
+ (remove not 
+ (map (lambda (color) (assq-ref ansi-color-tables color))
+  lst
+(if (null? color-list)
+""
+(string-append 
+ (string #\esc #\[)
+ (string-join color-list ";" 'infix)
+ "m"
+  
+(define (colorize-string str . color-list)
+  (string-append
+   (apply color color-list)
+   str
+   (color 'RESET)))
+
 ;;; ui.scm ends here
-- 
2.11.0



Re: Status of Submitted Patches

2018-05-24 Thread Sahitihi
Hi Ricardo,
> Another note about style: I think it would be better to use
> “alist->hash-table” instead of “make-hash-table” followed by repeated
> modifications to the hash table with “hashq-set!”.  We prefer to avoid
> mutation of values when possible.

I have made all necessary modifications. Can please review it once.
> Regarding copyright headers: please make sure to also add a copyright
> line for yourself and a copyright line from the file of guile-colorize
> to “(guix ui)”.
>
> When you’re done with these changes, please make a local commit and send
> the output of “git format-patch -1”.


I will proceed further once it is reviewed. :)

Thanks!!
---
Sahithi
(define-module (term ansi-color)
 #:export  (color
colorize-string)
 #:use-module (srfi srfi-1)   ; for 'remove'
 #:use-module (srfi srfi-13)) ; for 'string-join' 

(define ansi-color-tables
  `((CLEAR   .   "0")
(RESET   .   "0")
(BOLD.   "1")
(DARK.   "2")
(UNDERLINE   .   "4")
(UNDERSCORE  .   "4")
(BLINK   .   "5")
(REVERSE .   "6")
(CONCEALED   .   "8")
(BLACK   .  "30")
(RED .  "31")
(GREEN   .  "32")
(YELLOW  .  "33")
(BLUE.  "34")
(MAGENTA .  "35")
(CYAN.  "36")
(WHITE   .  "37")
(ON-BLACK.  "40")
(ON-RED  .  "41")
(ON-GREEN.  "42")
(ON-YELLOW   .  "43")
(ON-BLUE .  "44")
(ON-MAGENTA  .  "45")
(ON-CYAN .  "46")
(ON-WHITE.  "47")))

(define (color . lst)
  (let ((color-list 
 (remove not 
 (map (lambda (color) (assq-ref ansi-color-tables color))
  lst
(if (null? color-list)
""
(string-append 
 (string #\esc #\[)
 (string-join color-list ";" 'infix)
 "m"
  
(define (colorize-string str . color-list)
  (string-append
   (apply color color-list)
   str
   (color 'RESET)))

(display (colorize-string "Hello!\n" 'RED 'BOLD 'ON-BLUE))

(for-each display
  (list (color 'RED 'BOLD 'ON-BLUE)
"Hello!"
 (color 'RESET)))



Re: Status of Submitted Patches

2018-05-24 Thread Sahitihi
Hi Ricardo,
Done with changes and local commit
> When you’re done with these changes, please make a local commit and send
> the output of “git format-patch -1”.
the following is the output of  “git format-patch -1”

*/0001-Added-Colorize-module-to-Guix-ui.scm.patch/*

Can you please check and guide to proceed further.

Thanks!

--
Sahithi


Re: Fwd: Re: Patch file for colorize module

2018-06-09 Thread Sahitihi
Hi Ricardo,

When I used "(colorize-string "hello" '(GREEN))" in REPL that gave me a
error unbound variable colorize-string

When i used the same in attached file this gave me a colorless output

However when I tried with "(colorize-string "hello" 'GREEN)" in same
file this gave me colored output but in REPL still a unbound-variable.

So, I tried changing "(GREEN)" to "GREEN" in ui.scm but resulted with a
colorless output.

> I found the error already, but I’m sure you can too.  Here’s a hint:
> play around with “(colorize-string "hello" '(GREEN))”.  Does this look
> right?  If not, why is that?  Look closely at the definition of
> “colorize-string”.  What arguments does it expect?  How are arguments
> bound to variables?  How many arguments does “colorize-string” accept?
> Are you really sure about that…?
Attached file contains the details can you please review it once.

---
Thanks!
Sahithi
(define-module (term ansi-color)
 #:export  (color
colorize-string)
 #:use-module (srfi srfi-1))  ; for 'remove'

(define ansi-color-tables
  `((CLEAR   .   "0")
(RESET   .   "0")
(BOLD.   "1")
(DARK.   "2")
(UNDERLINE   .   "4")
(UNDERSCORE  .   "4")
(BLINK   .   "5")
(REVERSE .   "6")
(CONCEALED   .   "8")
(BLACK   .  "30")
(RED .  "31")
(GREEN   .  "32")
(YELLOW  .  "33")
(BLUE.  "34")
(MAGENTA .  "35")
(CYAN.  "36")
(WHITE   .  "37")
(ON-BLACK.  "40")
(ON-RED  .  "41")
(ON-GREEN.  "42")
(ON-YELLOW   .  "43")
(ON-BLUE .  "44")
(ON-MAGENTA  .  "45")
(ON-CYAN .  "46")
(ON-WHITE.  "47")))

(define (color . lst)

"The allowed values for the attributes are listed below.  Unknown
attributes are ignored.

@table @asis
@item Reset Attributes
@samp{CLEAR} and @samp{RESET} are allowed and equivalent.

@item Non-Color Attributes
@samp{BOLD} makes text bold, and @samp{DARK} reverses this.
@samp{UNDERLINE} and @samp{UNDERSCORE} are equivalent.  @samp{BLINK}
makes the text blink.  @samp{REVERSE} invokes reverse video.
@samp{CONCEALED} hides output (as for getting passwords, etc.).

@item Foregrond Color Attributes
@samp{BLACK}, @samp{RED}, @samp{GREEN}, @samp{YELLOW}, @samp{BLUE},
@samp{MAGENTA}, @samp{CYAN}, @samp{WHITE}

@item Background Color Attributes
@samp{ON-BLACK}, @samp{ON-RED}, @samp{ON-GREEN}, @samp{ON-YELLOW},
@samp{ON-BLUE}, @samp{ON-MAGENTA}, @samp{ON-CYAN}, @samp{ON-WHITE}
@end table"

  (let ((color-list 
 (remove not 
 (map (lambda (color) (assq-ref ansi-color-tables color))
  lst
(if (null? color-list)
""
(string-append 
 (string #\esc #\[)
 (string-join color-list ";" 'infix)
 "m"
  
(define (colorize-string str . color-list)
"Returns a copy of @var{str} colorized using ANSI
escape sequences according to the attributes specified in
@var{color-list}.  At the end of the returned string, the color
attributes will be reset such that subsequent output will not
have any colors in effect.

The allowed values for the attributes are listed in the
documentation for the @code{color} function."
  (string-append
   (apply color color-list)
   str
   (color 'RESET)))

(display (colorize-string "Hello!\n" 'RED))

(for-each display
  (list (color 'RED)
"Hello!"
 (color 'RESET)))



Re: Fwd: Re: Patch file for colorize module

2018-06-11 Thread Sahitihi
Hi Ricardo,

> You should see the same as I did.
This worked for me too.
> To see what’s going on with your modifications to “(guix ui)” it would
> help if you could go through your changes once more (use “git diff” to
> be sure to inspect all the lines you have changed) and send your changes
> to this list.
>
Image is attached. Though I made these changes to ui.scm still I
couldn't see the reflections in output.

---
Thanks!!
Sahithi.


Re: Fwd: Re: Patch file for colorize module

2018-06-11 Thread Sahitihi
Hi Gábor,

Updated patch is attached.

> Could you send an updated patch?

---
Thanks!!
Sahithi.
>From 765035232a43f09a5c3dbecf77c90499dd1473d4 Mon Sep 17 00:00:00 2001
From: Sahithi Yarlagadda 
Date: Tue, 5 Jun 2018 00:08:32 +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 |  5 +
 guix/ui.scm| 42 +-
 2 files changed, 42 insertions(+), 5 deletions(-)
 mode change 100644 => 100755 guix/scripts/build.scm
 mode change 100644 => 100755 guix/ui.scm

diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
old mode 100644
new mode 100755
index 4dd4fbccd..be457443b
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -732,10 +732,7 @@ needed."
   (with-store store
 ;; 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
old mode 100644
new mode 100755
index 80f1a4d77..83302ce30
--- 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,44 @@ be reset such that subsequent output will not have any colors in effect."
str
(color 'RESET)))
 
+ 
+(define (handle-string str)
+(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, so return unmodified string.
+   str)))
+(display message (current-error-port
+
+(define colorful-build-output-port
+  (make-soft-port
+   (vector
+(lambda (c) (write c (current-error-port)))
+handle-string
+(lambda () (display "." (current-error-port)))
+(lambda () (char-upcase (read-char)))
+(lambda () (display "@" (current-error-port
+   "rw"))
+
 ;;; ui.scm ends here
-- 
2.11.0



Re: Fwd: Re: Patch file for colorize module

2018-06-11 Thread Sahitihi
Hi Ricardo,

Text file is attached with all changes I added including colorize module.

The changes added to build.scm is (/(parameterize
((current-build-output-port  colorful-build-output-port)) /)

> Please send me the complete changes as a text file, so that I can apply
> it to my copy of the Guix repository.
>
---
Thanks!!
Sahithi.
(define color-table
  `((CLEAR   .   "0")
(RESET   .   "0")
(BOLD.   "1")
(DARK.   "2")
(UNDERLINE   .   "4")
(UNDERSCORE  .   "4")
(BLINK   .   "5")
(REVERSE .   "6")
(CONCEALED   .   "8")
(BLACK   .  "30")
(RED .  "31")
(GREEN   .  "32")
(YELLOW  .  "33")
(BLUE.  "34")
(MAGENTA .  "35")
(CYAN.  "36")
(WHITE   .  "37")
(ON-BLACK.  "40")
(ON-RED  .  "41")
(ON-GREEN.  "42")
(ON-YELLOW   .  "43")
(ON-BLUE .  "44")
(ON-MAGENTA  .  "45")
(ON-CYAN .  "46")
(ON-WHITE.  "47")))

(define (color . lst)
  "Return a string containing the ANSI escape sequence for producing the
requested set of attributes in LST.  Unknown attributes are ignored."
  (let ((color-list
 (remove not
 (map (lambda (color) (assq-ref color-table color))
  lst
(if (null? color-list)
""
(string-append
 (string #\esc #\[)
 (string-join color-list ";" 'infix)
 "m"

(define (colorize-string str . color-list)
  "Return a copy of STR colorized using ANSI escape sequences according to the
attributes STR.  At the end of the returned string, the color attributes will
be reset such that subsequent output will not have any colors in effect."
  (string-append
   (apply color color-list)
   str
   (color 'RESET)))

 
(define (handle-string str)
(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, so return unmodified string.
   str)))
(display message (current-error-port

(define colorful-build-output-port
  (make-soft-port
   (vector
(lambda (c) (write c (current-error-port)))
handle-string
(lambda () (display "." (current-error-port)))
(lambda () (char-upcase (read-char)))
(lambda () (display "@" (current-error-port
   "rw"))

;;; ui.scm ends here


Re: Fwd: Re: Patch file for colorize module

2018-06-08 Thread Sahitihi
Hi Ricardo,

I used this command but even this result with the colorless output.

> You need to use “./pre-inst-env guix” to use your modified version of
> Guix.
>
As per discussion in irc, I tried using "pk str" and  "(pk
(string-append …))" to show values.

I dint find any differences with and without pk.

I thought I overlooked, so I tried copying terminal lines to files and
compared.  I couldn't find differences except that of timing.

Can please help in figuring out where I went wrong.


Thanks!
Sahithi




Re: Next steps

2018-06-16 Thread Sahitihi
Hi Ricardo,

Patch file is attached with the following changes.
> Excellent, this looks better.  Unfortunately, your patch includes a
> couple of unrelated indentation changes.  Please remove those.
>
> 2) Fixing the other soft port procedures

As described I will proceed on with next steps and will make ensure to
complete it in-time.


Thanks!!
Sahithi
From 99526f5624633e5fdc72fe8fb280b1279bea0636 Mon Sep 17 00:00:00 2001
From: Sahithi Yarlagadda 
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



Re: Fwd: Re: Patch file for colorize module

2018-06-12 Thread Sahitihi
Hi Ricardo,

> I cannot seem to apply the patch onto either the “wip-sahithi” or
> “master” branches.  Could you rebase your changes on top of the
> “wip-sahithi” branch, please?  If that turns out to be too difficult,
> please rebase the changes on top of the current “master” branch after
> updating your clone of the git repository.

I have rebased the changes on "wip-sahithi" branch and sending the patch
file. I assume i cant rebase to "master" branch as the newly created
branch will have merge conflict with regard to ui.scm which is ahead of
master branch.

---
Thanks!!

Sahithi.
From a7bd2a2b9740d2e5134588d396672afbee33eb6a Mon Sep 17 00:00:00 2001
From: Sahithi Yarlagadda 
Date: Wed, 13 Jun 2018 02:08:27 +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| 41 -
 2 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index 4dd4fbccd..f6924874d 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..840ad82e8 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,43 @@ be reset such that subsequent output will not have any colors in effect."
str
(color 'RESET)))
 
+(define (handle-string str)
+(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, so return unmodified string.
+   str)))
+(display message (current-error-port
+
+(define colorful-build-output-port
+  (make-soft-port
+   (vector
+(lambda (c) (write c (current-error-port)))
+handle-string
+(lambda () (display "." (current-error-port)))
+(lambda () (char-upcase (read-char)))
+(lambda () (display "@" (current-error-port
+   "rw"))
+
 ;;; ui.scm ends here
-- 
2.11.0



Re: Fwd: Re: Patch file for colorize module

2018-06-15 Thread Sahitihi
Hi Ricardo,

I have fixed the errors mentioned bellow, Please do check and notify me
for further modifications.
>>> The next steps are to fix the errors in the regular expressions that
>>> swallow certain space characters and to re-read the documentation of
>>> “make-soft-port” to make sure that the procedures in the vector behave
>>> as they should.
>> I will update back once i am through with it.
I have added the comment lines. Patch file is attached. I applied indent
script please do not worry about that. :-)
> After reading the documentation for “make-soft-port” again, I recommend
> adding very short comments above each of the procedures in the vector to
> explain what they are intended to do.
>
Please do inform other modifications I have to do and next tasks to
proceed further.

---
Thanks!!
Sahithi.
From 2d4a335d0262e59784912b6cd922ae9283f17cb4 Mon Sep 17 00:00:00 2001
From: Sahithi Yarlagadda 
Date: Wed, 13 Jun 2018 02:08:27 +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| 101 -
 2 files changed, 75 insertions(+), 30 deletions(-)

diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index 4dd4fbccd..f6924874d 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..5ddc7c959 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -109,7 +109,7 @@
 warning
 info
 guix-main
-colorize-string))
+colorful-build-output-port))
 
 ;;; Commentary:
 ;;;
@@ -201,8 +201,8 @@ information, or #f if it could not be found."
   "Load the user provided Scheme source code FILE."
   (define (error-string frame args)
 (call-with-output-string
-  (lambda (port)
-(apply display-error frame port (cdr args)
+ (lambda (port)
+   (apply display-error frame port (cdr args)
 
   (define tag
 (make-prompt-tag "user-code"))
@@ -490,17 +490,17 @@ FILE."
 (augmented-system-error-handler file)
 
 (set! symlink
-  ;; We 'set!' the global binding because (gnu build ...) modules and similar
-  ;; typically don't use (guix ui).
-  (error-reporting-wrapper symlink (source target) target))
+  ;; We 'set!' the global binding because (gnu build ...) modules and similar
+  ;; typically don't use (guix ui).
+  (error-reporting-wrapper symlink (source target) target))
 
 (set! copy-file
-  ;; Note: here we use 'set!', not #:replace, because UIs typically use
-  ;; 'copy-recursively', which doesn't use (guix ui).
-  (error-reporting-wrapper copy-file (source target) target))
+  ;; Note: here we use 'set!', not #:replace, because UIs typically use
+  ;; 'copy-recursively', which doesn't use (guix ui).
+  (error-reporting-wrapper copy-file (source target) target))
 
 (set! canonicalize-path
-  (error-reporting-wrapper canonicalize-path (file) file))
+  (error-reporting-wrapper canonicalize-path (file) file))
 
 
 (define (make-regexp* regexp . flags)
@@ -898,10 +898,10 @@ replacement if PORT is not Unicode-capable."
 (catch 'encoding-error
   (lambda ()
 (call-with-output-string
-  (lambda (port)
-(set-port-encoding! port encoding)
-(set-port-conversion-strategy! port 'error)
-(display arrow port
+ (lambda (port)
+   (set-port-encoding! port encoding)
+   (set-port-conversion-strategy! port 'error)
+   (display arrow port
   (lambda (key . args)
 "->"
 
@@ -1086,7 +1086,7 @@ converted to a space; sequences of more than one line break are preserved."
   ;; 'texi-fragment->stexi' uses a string port so make sure it's a
   ;; Unicode-capable one (see .)
   (with-fluids ((%default-port-encoding "UTF-8"))
-(stexi->plain-text (texi-fragment->stexi str
+   (stexi->plain-text (texi-fragment->stexi str
 
 (define (package-field-string package field-accessor)
   "Return a plain-text representation of PACKAGE field."
@@ -1338,10 +1338,10 @@ DURATION-RELATION with the current time."
   ;; Return TIME at 

Re: Patch file for colorize module

2018-05-26 Thread Sahitihi
I went wrong in squashing. Please check the current attachment.

> Hi Ricardo,
>
>> I’d be happy if you could make these changes quickly and send an updated
>> patch.  Once I receive it I’ll push it to a branch “wip-sahithi” in the
>> repository.
>>
> I have made the above changes. Please notify if i have to make further
> changes.
>
> I mean while, I will be trying out using soft-ports.
>
> Thanks
>
> 
> Sahithi

>From f3411809f4c9d8e07abf76c08f65e9384405f7d7 Mon Sep 17 00:00:00 2001
From: root 
Date: Sat, 26 May 2018 17:34:23 +0530
Subject: [PATCH] ui: Add support for colorization.

* guix/ui.scm (ansi-color-tables): New variable.
(color, colorize-string): New procedures.
---
 guix/ui.scm | 58 --
 1 file changed, 56 insertions(+), 2 deletions(-)

diff --git a/guix/ui.scm b/guix/ui.scm
index 8d351607d..efbcbc88b 100755
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -9,7 +9,9 @@
 ;;; Copyright © 2015, 2016 Mathieu Lirzin 
 ;;; Copyright © 2016 Roel Janssen 
 ;;; Copyright © 2016 Benz Schenk 
-;;;
+;;; Copyright © 2013, 2014 Free Software Foundation, Inc.
+;;; Copyright © 2018 Sahithi Yarlagadda 
+;;; 
 ;;; This file is part of GNU Guix.
 ;;;
 ;;; GNU Guix is free software; you can redistribute it and/or modify it
@@ -106,7 +108,8 @@
 guix-warning-port
 warning
 info
-guix-main))
+guix-main
+colorize-string))
 
 ;;; Commentary:
 ;;;
@@ -1578,4 +1581,55 @@ and signal handling has already been set up."
   (initialize-guix)
   (apply run-guix args))
 
+(define color-table
+  `((CLEAR   .   "0")
+(RESET   .   "0")
+(BOLD.   "1")
+(DARK.   "2")
+(UNDERLINE   .   "4")
+(UNDERSCORE  .   "4")
+(BLINK   .   "5")
+(REVERSE .   "6")
+(CONCEALED   .   "8")
+(BLACK   .  "30")
+(RED .  "31")
+(GREEN   .  "32")
+(YELLOW  .  "33")
+(BLUE.  "34")
+(MAGENTA .  "35")
+(CYAN.  "36")
+(WHITE   .  "37")
+(ON-BLACK.  "40")
+(ON-RED  .  "41")
+(ON-GREEN.  "42")
+(ON-YELLOW   .  "43")
+(ON-BLUE .  "44")
+(ON-MAGENTA  .  "45")
+(ON-CYAN .  "46")
+(ON-WHITE.  "47")))
+
+(define (color . lst)
+"Returns a string containing the ANSI escape sequence for
+producing the requested set of attributes. Unknown attributes are ignored."
+  (let ((color-list 
+ (remove not 
+ (map (lambda (color) (assq-ref color-table color))
+  lst
+(if (null? color-list)
+""
+(string-append 
+ (string #\esc #\[)
+ (string-join color-list ";" 'infix)
+ "m"
+  
+(define (colorize-string str . color-list)
+  (string-append
+   (apply color color-list)
+   str
+   (color 'RESET)))
+"Returns a copy of @var{str} colorized using ANSI
+escape sequences according to the attributes. At the end of the returned string, the color
+attributes will be reset such that subsequent output will not
+have any colors in effect."
+
 ;;; ui.scm ends here
-- 
2.11.0



Re: Patch file for colorize module

2018-05-26 Thread Sahitihi
Hi Ricardo,

> I’d be happy if you could make these changes quickly and send an updated
> patch.  Once I receive it I’ll push it to a branch “wip-sahithi” in the
> repository.
>
I have made the above changes. Please notify if i have to make further
changes.

I mean while, I will be trying out using soft-ports.

Thanks


Sahithi
>From 64691615468bbb3e4b9e4bb2322a48c4b6a25d6d Mon Sep 17 00:00:00 2001
From: root 
Date: Sat, 26 May 2018 23:28:19 +0530
Subject: [PATCH] ui: Add support for colorization.

* guix/ui.scm (color-table): New variable.
(colorize-string): New procedure.
---
 guix/ui.scm | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/guix/ui.scm b/guix/ui.scm
index 20fbf761f..efbcbc88b 100755
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -9,7 +9,7 @@
 ;;; Copyright © 2015, 2016 Mathieu Lirzin 
 ;;; Copyright © 2016 Roel Janssen 
 ;;; Copyright © 2016 Benz Schenk 
-;;; Copyright © 2013,2014 Free Software Foundation, Inc.
+;;; Copyright © 2013, 2014 Free Software Foundation, Inc.
 ;;; Copyright © 2018 Sahithi Yarlagadda 
 ;;; 
 ;;; This file is part of GNU Guix.
@@ -109,7 +109,6 @@
 warning
 info
 guix-main
-color
 colorize-string))
 
 ;;; Commentary:
@@ -1582,7 +1581,7 @@ and signal handling has already been set up."
   (initialize-guix)
   (apply run-guix args))
 
-(define ansi-color-tables
+(define color-table
   `((CLEAR   .   "0")
 (RESET   .   "0")
 (BOLD.   "1")
@@ -1610,9 +1609,11 @@ and signal handling has already been set up."
 (ON-WHITE.  "47")))
 
 (define (color . lst)
+"Returns a string containing the ANSI escape sequence for
+producing the requested set of attributes. Unknown attributes are ignored."
   (let ((color-list 
  (remove not 
- (map (lambda (color) (assq-ref ansi-color-tables color))
+ (map (lambda (color) (assq-ref color-table color))
   lst
 (if (null? color-list)
 ""
@@ -1626,5 +1627,9 @@ and signal handling has already been set up."
(apply color color-list)
str
(color 'RESET)))
+"Returns a copy of @var{str} colorized using ANSI
+escape sequences according to the attributes. At the end of the returned string, the color
+attributes will be reset such that subsequent output will not
+have any colors in effect."
 
 ;;; ui.scm ends here
-- 
2.11.0



Re: Fwd: Re: Patch file for colorize module

2018-05-31 Thread Sahitihi
Hi Ricardo,

Sorry for delay. Next time I will make sure to run conversation via
email as well.
> Have you started on working on this yet?  If so,could you please give us
> an update on your progress via email?
>
I have started out using different functions like

|1) regexp-match 2) ||string-contains which resulted same output for strings 
then i tried 1)
string-match 2) string-substitute ended up using string substitute so
that the result can be colored one. But I failed executing it. File is
attached, Can u suggest where I went wrong. As per IRC discussion with
Ricardo, I tried installing emacs and running a shell.  Sahithi|||

(use-modules (ice-9 regex))
(use-modules (ice-9 colorized))
(activate-colorized)

(define p (make-soft-port
   (vector
(lambda (c) (write c stdout))
(regexp-substitute/global #t ("^starting phase.*"
"^phase .* succeeded.*"
"^phase .* failed.*")  "phase"
  'pre (lambda (s) (display (colorized-display s '(GREEN)) stdout))  'post)
(lambda () (display "." stdout))
(lambda () (char-upcase (read-char)))
(lambda () (display "@" stdout)))
   "rw"))
(write s p)



Re: Fwd: Re: Patch file for colorize module

2018-06-03 Thread Sahitihi
Hi Ricardo,

I have worked with different possibilities
> Now all you need to do is work on the “handle-string” procedure.
>
> I suggest using simpler matching procedures at first.  To get started
> try “string-prefix?” and use it with the string “starting phase”.  This
> won’t work with regular expressions, though.
String-prefix resulted a boolean output so, I thought of using conditionals.
Following is the line I added to  “handle-string” procedure

/(if (string-prefix? "starting phase" str) (colorized-display str
'(GREEN)) (display str target-port) ))


/
> While you *can* use “regexp-substitute/global”, I don’t think it’s a
> good fit here, because we may want to extend the string matching
> features, which is difficult to do with “regexp-substitute/global”.
> Instead, try to match regular expressions one by one with “string-match”
> and then operate on the match structure it returns.  If it returns #f
> you can move on to the next expression.  If none match you just return
> the original string.  If one matches you *rebuild* the string, but with
> colours applied.

Do I need to write multiple definitions for each expression?

'("^starting phase.*"
"^phase .* succeeded.*"
"^phase .* failed.*")

> If you don’t understand this example please look up the procedures in
> the Guile manual.

I dint find this example in procedures, may I overlooked somewhere I
recheck it.

Thanks!
Sahithi


Re: Fwd: Re: Patch file for colorize module

2018-06-04 Thread Sahitihi
Hi Ricardo,

I used /cond/ conditional  and gave a try. This worked out with
following line.

I also included string-match which also worked.

All I need to look for next step is to use regular expressions instead
of string.

> You also see that “if” alone is not sufficient here, because you have
> more than one expression.  You could nest “if” expressions, but that’s
> ugly.  You can use “cond” instead.
   /(cond ((string-match "(starting phase" str) (colorized-display str
'(GREEN))) //
//  ((string-prefix? "succeed" str) (colorized-display str
'(GREEN))) //
//  ((string-prefix? "failed" str) (colorized-display str
'(GREEN))) //
//  (else (display str target-port) )))/

> Please look at the examples in my previous email again.  I used
> “string-match”, “match:substring”, and “and=>”, which you may not be
> familiar with yet.
>

I used them individually but I still dint figure out the way it works in
the example. I will check that as next one.

Thanks!!

Sahithi


Re: Fwd: Re: Patch file for colorize module

2018-06-07 Thread Sahitihi
Hi Ricardo,

I used the following commands.

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

> Could you tell me the full command you used?
>
Earlier I got error with first command regarding display. After
correction to soft port that was fine.
Second command resulted colorless.
---
Sahithi


Re: Fwd: Re: Patch file for colorize module

2018-06-06 Thread Sahitihi
Hi Ricardo,

Please find my changes in the patch file attached.

>   (Generally, you really shouldn’t be developing things as
> “root”.)
>
This time I din't do it as root.
> For this commit a message like this would be appropriate:
Added a appropriate commit message.
> Please always add a so-called docstring for all defined procedures.
Please bear me for this time. I din't add this yet.
> You have probably noticed that this looks rather repetitive at this
> point.  Maybe we can think of a better way to express what colours
> should be applied.  The match group numbers are monotonically
> increasing, so maybe we can avoid repeated statements of this kind and
> simply iterate over a list of colours…  I have an idea already; how
> about you?  :)

I have an idea about making a using filter-string and lists. Not sure
about functionality but that seems fine. :-P
> Another thing that’s worth thinking about now is the next step:
> how can we *optionally* hide all lines between these build system
> notices about started and completed build phases?
I din't think of it yet. Will do it in mean process.
> One more thing: the fact that handle-string didn’t do the right thing
> indicates that you didn’t test the changes well enough.  To test them,
> please locally modify “guix/scripts/build.scm” and/or
> “guix/scripts/package.scm” to make it use your colourful port instead of
> the default, as discussed on IRC and in previous emails.
I made changes to /guix/scripts/build.scm  /but that din/t workout. That
resulted me colourless outputs as before. :-(


Thanks!
Sahithi
From ee2f26b05093cc3227a37b96196ec3a29182 Mon Sep 17 00:00:00 2001
From: Sahithi Yarlagadda 
Date: Thu, 7 Jun 2018 00:07:34 +0530
Subject: [PATCH 2/2] guix: Add coloring soft port.

* guix/ui.scm (handle-string): New procedures.
(colorful-build-output-port): New variable.
---
 guix/ui.scm | 41 -
 1 file changed, 20 insertions(+), 21 deletions(-)
 mode change 100644 => 100755 guix/ui.scm

diff --git a/guix/ui.scm b/guix/ui.scm
old mode 100644
new mode 100755
index 3a36daadc..51a1c4a46
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -109,8 +109,7 @@
 warning
 info
 guix-main
-colorize-string
-guix-colorful-port))
+colorful-build-output-port))
 
 ;;; Commentary:
 ;;;
@@ -1632,43 +1631,43 @@ be reset such that subsequent output will not have any colors in effect."
str
(color 'RESET)))
 
-(define target-port (current-output-port))
  
 (define (handle-string str)
(or (and=> (string-match "^(starting phase)(.*)" str)
(lambda (m)
  (string-append
-   (colorized-display (match:substring m 1) '(BLUE))
-   (colorized-display (match:substring m 2) '(GREEN)
+   (colorize-string (match:substring m 1) '(BLUE))
+   (colorize-string (match:substring m 2) '(GREEN)
 
-   (and=> (string-match "^(phase)(.*) (succeeded)(.*)" str)
+   (and=> (string-match "^(phase) (.*) (succeeded after) (.*) (seconds)" str)
   (lambda (m)
 (string-append
-  (colorized-display (match:substring m 1) '(BLUE))
-  (colorized-display (match:substring m 2) '(GREEN))
-  (colorized-display (match:substring m 3) '(BLUE))
-  (colorized-display (match:substring m 4) '(GREEN)
+  (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)(.*)" str)
+   (and=> (string-match "^(phase)(.*) (failed after) (.*) (seconds)" str)
   (lambda (m)
 (string-append
-  (colorized-display (match:substring m 1) '(BLUE))
-  (colorized-display (match:substring m 2) '(GREEN))
-  (colorized-display (match:substring m 3) '(BLUE))
-  (colorized-display (match:substring m 4) '(GREEN)
+  (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, so return unmodified string.
-  str)
- (display str target-port))
+   (display str current-error-port)))
 
-(define guix-colorful-port
+(define colorful-build-output-port
   (make-soft-port
(vector
-(lambda (c) (write c target-port))
+(lambda (c) (write c current-error-port))
 handle-string
-(lambda () (display "." target-port))
+(lambda () (display "." current-error-port))
 (lambda () (char-upcase (read-char)))
-(lambda 

Re: Fwd: Re: Patch file for colorize module

2018-06-06 Thread Sahitihi
Hi Ricardo,

Patch file is attached with changes.

I modified guix/scripts/build.scm
   /(parameterize ((current-build-output-port (if quiet?//
// (%make-void-port
"w")//
// 
(current-error-port//
/
to by REPLACING this to use colored output

  /(parameterize ((current-build-output-port 
colorful-build-output-port))/


UI.scm had the necessary changes.


I am getting the following error when building a package

/In ice-9/boot-9.scm://
//    837:9  6 (catch _ _ # ?)//
//    837:9  5 (catch _ _ # ?)//
//In guix/scripts/build.scm://
//   781:24  4 (_)//
//In guix/store.scm://
//   936:15  3 (_ # _ _)//
//   620:13  2 (process-stderr _ _)//
//In unknown file://
//   1 (display "@ build-started /gnu/store/gxv20gis2i4xk8nmn?" ?)//
//   0 (display "@ build-started /gnu/store/gxv20gis2i4xk8nmn?" ?)//
//
//ERROR: In procedure display://
//ERROR: In procedure display: Wrong type argument in position 2:
#«parameter> 870600 proc: #From 3b74ea60a13fef3141f4bedb52f9e8131aaec101 Mon Sep 17 00:00:00 2001
From: Sahithi Yarlagadda 
Date: Tue, 5 Jun 2018 00:08:32 +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 |  5 +
 guix/ui.scm| 42 +-
 2 files changed, 42 insertions(+), 5 deletions(-)
 mode change 100644 => 100755 guix/scripts/build.scm
 mode change 100644 => 100755 guix/ui.scm

diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
old mode 100644
new mode 100755
index 4dd4fbccd..be457443b
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -732,10 +732,7 @@ needed."
   (with-store store
 ;; 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
old mode 100644
new mode 100755
index 80f1a4d77..7774cf78c
--- 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,44 @@ be reset such that subsequent output will not have any colors in effect."
str
(color 'RESET)))
 
+ 
+(define (handle-string str)
+(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, so return unmodified string.
+   str)))
+(display message (current-error-port
+
+(define colorful-build-output-port
+  (make-soft-port
+   (vector
+(lambda (c) (write c current-error-port))
+handle-string
+(lambda () (display "." current-error-port))
+(lambda () (char-upcase (read-char)))
+(lambda () (display "@" current-error-port)))
+   "rw"))
+
 ;;; ui.scm ends here
-- 
2.11.0



Introducing myself as an Outreachy Intern

2018-04-25 Thread Sahitihi
Hi all,

I Sahithi Yarlagadda, a Free Software enthusiast. I am from India,
pursuing my under graduation final semester in Computer Science. I will
be working as an Outreachy Intern for May-August 2018. I am glad to be
part of Guix Community. I have been working with Ricardo Wurmus during
the application process. He helped me in understanding and working with
Guix. Community has given a great support, expecting the same till the end.

During the process of application, The following are the few tasks that
I worked out

1. Adding package definitions like r-dyn, r-catdap, r-abc to CRAN Packages .

2. Printed colored strings on terminal using Scheme code

3. Looked at scheme code to find out build output is printed.


Regards,

Sahithi