]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
demos/file_uploader: add missing __name__ == __main__ stanza 2245/head
authorJehiah Czebotar <jehiah@gmail.com>
Tue, 30 May 2017 13:27:15 +0000 (09:27 -0400)
committerPierce Lopez <pierce.lopez@gmail.com>
Sun, 7 Jan 2018 02:21:41 +0000 (21:21 -0500)
demos/file_upload/file_uploader.py [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 9678969..9f1f84d
@@ -100,13 +100,14 @@ def put(filenames):
         print(response)
 
 
-define("put", type=bool, help="Use PUT instead of POST", group="file uploader")
+if __name__ == "__main__":
+    define("put", type=bool, help="Use PUT instead of POST", group="file uploader")
 
-# Tornado configures logging from command line opts and returns remaining args.
-filenames = options.parse_command_line()
-if not filenames:
-    print("Provide a list of filenames to upload.", file=sys.stderr)
-    sys.exit(1)
+    # Tornado configures logging from command line opts and returns remaining args.
+    filenames = options.parse_command_line()
+    if not filenames:
+        print("Provide a list of filenames to upload.", file=sys.stderr)
+        sys.exit(1)
 
-method = put if options.put else post
-ioloop.IOLoop.current().run_sync(lambda: method(filenames))
+    method = put if options.put else post
+    ioloop.IOLoop.current().run_sync(lambda: method(filenames))