You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/02/04 08:46:36 UTC

[GitHub] csantanapr closed pull request #11: Pass arguments using stdin rather than env param.

csantanapr closed pull request #11: Pass arguments using stdin rather than env param.
URL: https://github.com/apache/incubator-openwhisk-runtime-swift/pull/11
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/core/actionProxy/actionproxy.py b/core/actionProxy/actionproxy.py
index 10ee2a9..c7f74ba 100644
--- a/core/actionProxy/actionproxy.py
+++ b/core/actionProxy/actionproxy.py
@@ -129,7 +129,8 @@ def error(msg):
         try:
             input = json.dumps(args)
             p = subprocess.Popen(
-                [self.binary, input],
+                [self.binary],
+                stdin=subprocess.PIPE,
                 stdout=subprocess.PIPE,
                 stderr=subprocess.PIPE,
                 env=env)
@@ -138,7 +139,7 @@ def error(msg):
 
         # run the process and wait until it completes.
         # stdout/stderr will always be set because we passed PIPEs to Popen
-        (o, e) = p.communicate()
+        (o, e) = p.communicate(input=input.encode())
 
         # stdout/stderr may be either text or bytes, depending on Python
         # version, so if bytes, decode to text. Note that in Python 2
diff --git a/core/swift3.1.1Action/epilogue.swift b/core/swift3.1.1Action/epilogue.swift
index fd1b6a8..814b066 100644
--- a/core/swift3.1.1Action/epilogue.swift
+++ b/core/swift3.1.1Action/epilogue.swift
@@ -42,7 +42,7 @@ func _whisk_json2dict(txt: String) -> [String:Any]? {
 
 func _run_main(mainFunction: ([String: Any]) -> [String: Any]) -> Void {
     let env = ProcessInfo.processInfo.environment
-    let inputStr: String = env["WHISK_INPUT"] ?? "{}"
+    let inputStr: String = readLine() ?? "{}"
 
     if let parsed = _whisk_json2dict(txt: inputStr) {
         let result = mainFunction(parsed)
diff --git a/core/swift4Action/epilogue.swift b/core/swift4Action/epilogue.swift
index e6a9b15..3e98ec6 100644
--- a/core/swift4Action/epilogue.swift
+++ b/core/swift4Action/epilogue.swift
@@ -2,10 +2,9 @@
 import Foundation
 
 let env = ProcessInfo.processInfo.environment
-let inputStr: String = env["WHISK_INPUT"] ?? "{}"
+let inputStr: String = readLine() ?? "{}"
 let json = inputStr.data(using: .utf8, allowLossyConversion: true)!
 
-
 // snippet of code "injected" (wrapper code for invoking traditional main)
 func _run_main(mainFunction: ([String: Any]) -> [String: Any]) -> Void {
     let parsed = try! JSONSerialization.jsonObject(with: json, options: []) as! [String: Any]


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services