mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-12 05:17:38 +00:00
style: format python files with isort and double-quote-string-fixer
This commit is contained in:
@@ -14,12 +14,11 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
from builtins import str
|
||||
from builtins import range
|
||||
import http.client
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import argparse
|
||||
import http.client
|
||||
from builtins import range, str
|
||||
|
||||
from tiny_test_fw import Utility
|
||||
|
||||
@@ -33,41 +32,41 @@ def end_session(conn):
|
||||
|
||||
|
||||
def getreq(conn, path, verbose=False):
|
||||
conn.request("GET", path)
|
||||
conn.request('GET', path)
|
||||
resp = conn.getresponse()
|
||||
data = resp.read()
|
||||
if verbose:
|
||||
Utility.console_log("GET : " + path)
|
||||
Utility.console_log("Status : " + resp.status)
|
||||
Utility.console_log("Reason : " + resp.reason)
|
||||
Utility.console_log("Data length : " + str(len(data)))
|
||||
Utility.console_log("Data content : " + data)
|
||||
Utility.console_log('GET : ' + path)
|
||||
Utility.console_log('Status : ' + resp.status)
|
||||
Utility.console_log('Reason : ' + resp.reason)
|
||||
Utility.console_log('Data length : ' + str(len(data)))
|
||||
Utility.console_log('Data content : ' + data)
|
||||
return data
|
||||
|
||||
|
||||
def postreq(conn, path, data, verbose=False):
|
||||
conn.request("POST", path, data)
|
||||
conn.request('POST', path, data)
|
||||
resp = conn.getresponse()
|
||||
data = resp.read()
|
||||
if verbose:
|
||||
Utility.console_log("POST : " + data)
|
||||
Utility.console_log("Status : " + resp.status)
|
||||
Utility.console_log("Reason : " + resp.reason)
|
||||
Utility.console_log("Data length : " + str(len(data)))
|
||||
Utility.console_log("Data content : " + data)
|
||||
Utility.console_log('POST : ' + data)
|
||||
Utility.console_log('Status : ' + resp.status)
|
||||
Utility.console_log('Reason : ' + resp.reason)
|
||||
Utility.console_log('Data length : ' + str(len(data)))
|
||||
Utility.console_log('Data content : ' + data)
|
||||
return data
|
||||
|
||||
|
||||
def putreq(conn, path, body, verbose=False):
|
||||
conn.request("PUT", path, body)
|
||||
conn.request('PUT', path, body)
|
||||
resp = conn.getresponse()
|
||||
data = resp.read()
|
||||
if verbose:
|
||||
Utility.console_log("PUT : " + path, body)
|
||||
Utility.console_log("Status : " + resp.status)
|
||||
Utility.console_log("Reason : " + resp.reason)
|
||||
Utility.console_log("Data length : " + str(len(data)))
|
||||
Utility.console_log("Data content : " + data)
|
||||
Utility.console_log('PUT : ' + path, body)
|
||||
Utility.console_log('Status : ' + resp.status)
|
||||
Utility.console_log('Reason : ' + resp.reason)
|
||||
Utility.console_log('Data length : ' + str(len(data)))
|
||||
Utility.console_log('Data content : ' + data)
|
||||
return data
|
||||
|
||||
|
||||
@@ -85,22 +84,22 @@ if __name__ == '__main__':
|
||||
N = args['N']
|
||||
|
||||
# Establish HTTP connection
|
||||
Utility.console_log("Connecting to => " + ip + ":" + port)
|
||||
Utility.console_log('Connecting to => ' + ip + ':' + port)
|
||||
conn = start_session(ip, port)
|
||||
|
||||
# Reset adder context to specified value(0)
|
||||
# -- Not needed as new connection will always
|
||||
# -- have zero value of the accumulator
|
||||
Utility.console_log("Reset the accumulator to 0")
|
||||
putreq(conn, "/adder", str(0))
|
||||
Utility.console_log('Reset the accumulator to 0')
|
||||
putreq(conn, '/adder', str(0))
|
||||
|
||||
# Sum numbers from 1 to specified value(N)
|
||||
Utility.console_log("Summing numbers from 1 to " + str(N))
|
||||
Utility.console_log('Summing numbers from 1 to ' + str(N))
|
||||
for i in range(1, N + 1):
|
||||
postreq(conn, "/adder", str(i))
|
||||
postreq(conn, '/adder', str(i))
|
||||
|
||||
# Fetch the result
|
||||
Utility.console_log("Result :" + getreq(conn, "/adder"))
|
||||
Utility.console_log('Result :' + getreq(conn, '/adder'))
|
||||
|
||||
# Close HTTP connection
|
||||
end_session(conn)
|
||||
|
Reference in New Issue
Block a user