[OE-core] [PATCH 2/2] report-error: send report error with username and email

João Henrique Ferreira de Freitas joaohf at gmail.com
Wed Nov 12 23:08:39 UTC 2014


Two variables ERR_REPORT_USER and ERR_REPORT_EMAIL were created
to instruct send-report-error to use 'user' and 'email' from command
line parameters instead of checking '~/.oe-send-error' file.

Two new positional arguments were added to send-report-error.
If 'username' (third argument) is passed, then send-error-report will
not check userfile. As 'email' (forth argument) is an optional,
it will used only if passed.

Signed-off-by: João Henrique Ferreira de Freitas <joaohf at gmail.com>
---
 meta/classes/report-error.bbclass |  6 +++++-
 scripts/send-error-report         | 45 ++++++++++++++++++++++++---------------
 2 files changed, 33 insertions(+), 18 deletions(-)

diff --git a/meta/classes/report-error.bbclass b/meta/classes/report-error.bbclass
index f9e821f..253a659 100644
--- a/meta/classes/report-error.bbclass
+++ b/meta/classes/report-error.bbclass
@@ -8,6 +8,8 @@
 
 ERR_REPORT_DIR ?= "${LOG_DIR}/error-report"
 ERR_REPORT_SERVER ?= ""
+ERR_REPORT_USER ?= ""
+ERR_REPORT_EMAIL ?= ""
 
 def errorreport_getdata(e):
     logpath = e.data.getVar('ERR_REPORT_DIR', True)
@@ -29,7 +31,9 @@ def errorreport_senddata(e, datafile):
     import subprocess
     server = e.data.getVar('ERR_REPORT_SERVER', True)
     if server:
-        cmd = 'send-error-report %s %s' % (datafile, server)
+        user = e.data.getVar('ERR_REPORT_USER', True)
+        email = e.data.getVar('ERR_REPORT_EMAIL', True)
+        cmd = 'send-error-report %s %s %s %s' % (datafile, server, user, email)
         subprocess.call(cmd, shell=True)
     else:
         bb.note("The errors for this build are stored in %s\nYou can send the errors to an upstream server by running:\n  send-error-report %s [server]" % (datafile, datafile))
diff --git a/scripts/send-error-report b/scripts/send-error-report
index c99d387..b5c4972 100755
--- a/scripts/send-error-report
+++ b/scripts/send-error-report
@@ -42,27 +42,35 @@ def handle_connection(server, data):
     return conn
 
 
-def sendData(json_file, server):
+def sendData(json_file, server, username = '', email = ''):
 
     if os.path.isfile(json_file):
 
-        home = os.path.expanduser("~")
-        userfile = os.path.join(home, ".oe-send-error")
-        if os.path.isfile(userfile):
-            with open(userfile) as g:
-                username = g.readline()
-                email = g.readline()
+        if username:
+            if len(username) > 0 and len(username) > 50:
+                print("Invalid username input, try again.")
+                return
+            if len(email) > 0 and len(email) > 50:
+                print("Invalid username input, try again.")
+                return
         else:
-            print("Please enter your name and your email (optionally), they'll be saved in the file you send.")
-            username = raw_input("Name: ")
-            email = raw_input("E-mail (not required): ")
-            if len(username) > 0 and len(username) < 50:
-                with open(userfile, "w") as g:
-                    g.write(username + "\n")
-                    g.write(email + "\n")
+            home = os.path.expanduser("~")
+            userfile = os.path.join(home, ".oe-send-error")
+            if os.path.isfile(userfile):
+                with open(userfile) as g:
+                    username = g.readline()
+                    email = g.readline()
             else:
-                print("Invalid inputs, try again.")
-                return
+                print("Please enter your name and your email (optionally), they'll be saved in the file you send.")
+                username = raw_input("Name: ")
+                email = raw_input("E-mail (not required): ")
+                if len(username) > 0 and len(username) < 50:
+                    with open(userfile, "w") as g:
+                        g.write(username + "\n")
+                        g.write(email + "\n")
+                else:
+                    print("Invalid inputs, try again.")
+                    return
 
         with open(json_file) as f:
             data = f.read()
@@ -103,8 +111,11 @@ if __name__ == '__main__':
         print("\nUsage: send-error-report <error_fileName> [server]")
         print("\nIf this is the first when sending a report you'll be asked for your name and optionally your email address.")
         print("They will be associated with your report.\n")
-
     elif len(sys.argv) == 3:
         sendData(sys.argv[1], sys.argv[2])
+    elif len(sys.argv) == 4:
+        sendData(sys.argv[1], sys.argv[2], sys.argv[3])
+    elif len(sys.argv) == 5:
+        sendData(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
     else:
         sendData(sys.argv[1], "errors.yoctoproject.org")
-- 
1.9.1




More information about the Openembedded-core mailing list