diff --git a/qemu/deps/cdrom/tray_open.py b/qemu/deps/cdrom/tray_open.py index 18d6cbad04e1e66a3bbc8adcb5d7180e387042c3..4bafcb5fcd5b9e2fa98fd7c3e4567a68ac62c025 100644 --- a/qemu/deps/cdrom/tray_open.py +++ b/qemu/deps/cdrom/tray_open.py @@ -8,9 +8,9 @@ if len(sys.argv) > 1: fd = os.open(sys.argv[1], os.O_RDONLY | os.O_NONBLOCK) if CDROM.CDS_TRAY_OPEN == fcntl.ioctl(fd, CDROM.CDROM_DRIVE_STATUS): - print "cdrom is open" + print("cdrom is open") else: - print "cdrom is close" + print("cdrom is close") os.close(fd) else: @@ -19,6 +19,6 @@ if len(sys.argv) > 1: ctypes.windll.WINMM.mciSendStringW(msg, None, 0, None) msg = u"status d_drive length" if ctypes.windll.WINMM.mciSendStringW(msg, None, 0, None) == 0: - print "cdrom is close" + print("cdrom is close") else: - print "cdrom is open" + print("cdrom is open") diff --git a/qemu/deps/softlockup/heartbeat_slu.py b/qemu/deps/softlockup/heartbeat_slu.py index b65e4240b6cb7928bdf627133f24b8f5d4a99392..8bff529e29b80a9a6a842f2c611195e4e64f0b14 100755 --- a/qemu/deps/softlockup/heartbeat_slu.py +++ b/qemu/deps/softlockup/heartbeat_slu.py @@ -14,7 +14,7 @@ import getopt def daemonize(output_file): try: pid = os.fork() - except OSError, e: + except OSError as e: raise Exception("error %d: %s" % (e.strerror, e.errno)) if pid: @@ -26,12 +26,12 @@ def daemonize(output_file): sys.stderr.flush() if output_file: - output_handle = file(output_file, 'a+', 0) + output_handle = open(output_file, 'a+', 0) # autoflush stdout/stderr sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0) else: - output_handle = file('/dev/null', 'a+') + output_handle = open('/dev/null', 'a+') stdin_handle = open('/dev/null', 'r') os.dup2(output_handle.fileno(), sys.stdout.fileno()) @@ -70,9 +70,9 @@ def run_server(host, port, daemon, path, queue_size, threshold, drift): prev_check_timestamp = local_timestamp if verbose: if check_drift: - print "%.2f: %s (%s)" % (local_timestamp, heartbeat, drift) + print("%.2f: %s (%s)" % (local_timestamp, heartbeat, drift)) else: - print "%.2f: %s" % (local_timestamp, heartbeat) + print("%.2f: %s" % (local_timestamp, heartbeat)) def run_client(host, port, daemon, path, interval): @@ -87,9 +87,10 @@ def run_client(host, port, daemon, path, interval): sock.sendall(heartbeat) sock.close() if verbose: - print heartbeat - except socket.error, (value, message): - print "%.2f: ERROR, %d - %s" % (float(time.time()), value, message) + print(heartbeat) + except socket.error as message: + print("%.2f: ERROR - %s" + % (float(time.time()), message)) seq += 1 time.sleep(interval) @@ -102,16 +103,16 @@ def get_heartbeat(seq=1): def check_heartbeat(heartbeat, local_timestamp, threshold, check_drift): hostname, _, timestamp = heartbeat.rsplit() timestamp = float(timestamp) - if client_prev_timestamp.has_key(hostname): + if hostname in client_prev_timestamp: delta = local_timestamp - client_prev_timestamp[hostname] if delta > threshold: - print ("%.2f: ALERT, SLU detected on host %s, delta %ds" % - (float(time.time()), hostname, delta)) + print("%.2f: ALERT, SLU detected on host %s, delta %ds" % + (float(time.time()), hostname, delta)) client_prev_timestamp[hostname] = local_timestamp if check_drift: - if not client_clock_offset.has_key(hostname): + if hostname not in client_clock_offset: client_clock_offset[hostname] = timestamp - local_timestamp client_prev_drift[hostname] = 0 drift = timestamp - local_timestamp - client_clock_offset[hostname] @@ -127,8 +128,8 @@ def check_for_timeouts(threshold, check_drift): timestamp = client_prev_timestamp[hostname] delta = local_timestamp - timestamp if delta > threshold * 2: - print ("%.2f: ALERT, SLU detected on host %s, no heartbeat for %ds" - % (local_timestamp, hostname, delta)) + print("%.2f: ALERT, SLU detected on host %s, no heartbeat for %ds" + % (local_timestamp, hostname, delta)) del client_prev_timestamp[hostname] if check_drift: del client_clock_offset[hostname] @@ -136,7 +137,7 @@ def check_for_timeouts(threshold, check_drift): def usage(): - print """ + print(""" Usage: heartbeat_slu.py --server --address --port @@ -146,7 +147,7 @@ Usage: heartbeat_slu.py --client --address -p [--file output_file] [--no-daemon] [--verbose] [--interval ] -""" +""") # host information and global data @@ -175,8 +176,8 @@ try: "server", "client", "no-daemon", "address=", "port=", "file=", "server", "interval=", "threshold=", "verbose", "check-drift", "help"]) -except getopt.GetoptError, e: - print "error: %s" % str(e) +except getopt.GetoptError as e: + print("error: %s" % str(e)) usage() sys.exit(1) @@ -205,7 +206,7 @@ for param, value in opts: usage() sys.exit(0) else: - print "error: unrecognized option: %s" % value + print("error: unrecognized option: %s" % value) usage() sys.exit(1) diff --git a/qemu/deps/spice/build_install.py b/qemu/deps/spice/build_install.py index 18521892e84a574cf728de7efd8a5160802e6172..1f94614787626d29af264047fcd8ca2019a881ce 100755 --- a/qemu/deps/spice/build_install.py +++ b/qemu/deps/spice/build_install.py @@ -80,7 +80,7 @@ parser.add_option("--tarball", dest="tarballLocation", (options, args) = parser.parse_args() if not options.pkgName: - print "Missing required arguments" + print("Missing required arguments") parser.print_help() sys.exit(1) @@ -98,7 +98,7 @@ if options.gitRepo: f = open("/etc/redhat-release", "r") rhelVersion = f.read() -print "OS: %s" % rhelVersion +print("OS: %s" % rhelVersion) if re.findall("release 6", rhelVersion): if pkgName in ("spice-gtk", "virt-viewer"): autogen_options[pkgName] += " --with-gtk=2.0" @@ -113,7 +113,7 @@ if not tarballLocation: ret = os.system("which git") if ret != 0: - print "Missing git command!" + print("Missing git command!") sys.exit(1) # Create destination directory @@ -121,12 +121,12 @@ if not tarballLocation: basename = git_repo[pkgName].split("/")[-1] destDir = os.path.join("/tmp", basename) if os.path.exists(destDir): - print "Deleting existing destination directory" + print("Deleting existing destination directory") subprocess.check_call(("rm -rf %s" % destDir).split()) # If destination directory doesn't exist, create it if not os.path.exists(destDir): - print "Creating directory %s for git repo %s" % (destDir, git_repo[pkgName]) + print("Creating directory %s for git repo %s" % (destDir, git_repo[pkgName])) os.makedirs(destDir) # Switch to the directory @@ -134,46 +134,46 @@ if not tarballLocation: # If git repo already exists, reset. If not, initialize if os.path.exists('.git'): - print "Resetting previously existing git repo at %s for receiving git repo %s" % (destDir, git_repo[pkgName]) + print("Resetting previously existing git repo at %s for receiving git repo %s" % (destDir, git_repo[pkgName])) subprocess.check_call("git reset --hard".split()) else: - print "Initializing new git repo at %s for receiving git repo %s" % (destDir, git_repo[pkgName]) + print("Initializing new git repo at %s for receiving git repo %s" % (destDir, git_repo[pkgName])) subprocess.check_call("git init".split()) # Fetch the contents of the repo - print "Fetching git [REP '%s' BRANCH '%s'] -> %s" % (git_repo[pkgName], branch, destDir) + print("Fetching git [REP '%s' BRANCH '%s'] -> %s" % (git_repo[pkgName], branch, destDir)) subprocess.check_call(("git fetch -q -f -u -t %s %s:%s" % (git_repo[pkgName], branch, branch)).split()) # checkout the branch specified, master by default - print "Checking out branch %s" % branch + print("Checking out branch %s" % branch) subprocess.check_call(("git checkout %s" % branch).split()) # If a certain commit is specified, checkout that commit if commit is not None: - print "Checking out commit %s" % commit + print("Checking out commit %s" % commit) subprocess.check_call(("git checkout %s" % commit).split()) else: - print "Specific commit not specified" + print("Specific commit not specified") # Adding remote origin - print "Adding remote origin" + print("Adding remote origin") args = ("git remote add origin %s" % git_repo[pkgName]).split() output = run_subprocess_cmd(args) # Get the commit and tag which repo is at args = 'git log --pretty=format:%H -1'.split() - print "Running 'git log --pretty=format:%H -1' to get top commit" + print("Running 'git log --pretty=format:%H -1' to get top commit") top_commit = run_subprocess_cmd(args) args = 'git describe'.split() - print "Running 'git describe' to get top tag" + print("Running 'git describe' to get top tag") top_tag = run_subprocess_cmd(args) if top_tag is None: top_tag_desc = 'no tag found' else: top_tag_desc = 'tag %s' % top_tag - print "git commit ID is %s (%s)" % (top_commit, top_tag_desc) + print("git commit ID is %s (%s)" % (top_commit, top_tag_desc)) # If tarball is not specified else: @@ -211,7 +211,7 @@ cmd = destDir + "/autogen.sh" if not os.path.exists(cmd): cmd = destDir + "/configure" if not os.path.exists(cmd): - print "%s doesn't exist! Something's wrong!" % cmd + print("%s doesn't exist! Something's wrong!" % cmd) sys.exit(1) if prefix is not None: @@ -219,10 +219,10 @@ if prefix is not None: if pkgName in autogen_options.keys(): cmd += " " + autogen_options[pkgName] -print "Running '%s %s'" % (env_vars, cmd) +print("Running '%s %s'" % (env_vars, cmd)) ret = os.system(env_vars + " " + cmd) if ret != 0: - print "Return code: %s! Autogen.sh failed! Exiting!" % ret + print("Return code: %s! Autogen.sh failed! Exiting!" % ret) sys.exit(1) # Temporary workaround for building spice-vdagent @@ -232,16 +232,16 @@ if pkgName == "spice-vd-agent": # Running 'make' to build and using os.system again cmd = "make" -print "Running '%s %s'" % (env_vars, cmd) +print("Running '%s %s'" % (env_vars, cmd)) ret = os.system("%s %s" % (env_vars, cmd)) if ret != 0: - print "Return code: %s! make failed! Exiting!" % ret + print("Return code: %s! make failed! Exiting!" % ret) sys.exit(1) # Running 'make install' to install the built libraries/binaries cmd = "make install" -print "Running '%s %s'" % (env_vars, cmd) +print("Running '%s %s'" % (env_vars, cmd)) ret = os.system("%s %s" % (env_vars, cmd)) if ret != 0: - print "Return code: %s! make install failed! Exiting!" % ret + print("Return code: %s! make install failed! Exiting!" % ret) sys.exit(ret) diff --git a/qemu/deps/win_driver_install/win_driver_install.py b/qemu/deps/win_driver_install/win_driver_install.py index 24d9f13d002a8b906b06018203612d9602568e9b..8063c127b1a09ed786775246bd1dda6bd9ab9dc9 100644 --- a/qemu/deps/win_driver_install/win_driver_install.py +++ b/qemu/deps/win_driver_install/win_driver_install.py @@ -167,7 +167,7 @@ def show_log_output(result_file): :param result_file: File which saves execution logs. """ with open(result_file) as fd: - print os.linesep.join(fd.readlines()) + print(os.linesep.join(fd.readlines())) if __name__ == "__main__": @@ -229,7 +229,7 @@ if __name__ == "__main__": verify_driver_ver(arguments.driver_path, arguments.device_name, arguments.driver_name) elif arguments.log_output: - print "Execution log:\n" + print("Execution log:\n") show_log_output(result_file) - print "DPINST.log:\n" + print("DPINST.log:\n") show_log_output(r"C:\Windows\DPINST.log") diff --git a/qemu/deps/win_serial/VirtIoChannel_guest_recieve.py b/qemu/deps/win_serial/VirtIoChannel_guest_recieve.py index 8c5672169494e4ea4d3a762cab359525e1b8163d..cbf50ec39ee83b61d7000ed833ab10e65f613ff5 100755 --- a/qemu/deps/win_serial/VirtIoChannel_guest_recieve.py +++ b/qemu/deps/win_serial/VirtIoChannel_guest_recieve.py @@ -103,7 +103,7 @@ def test(path): else: vport_name = '/dev/virtio-ports/' + path vio = VirtIoChannel(vport_name) - print vio.read() + print(vio.read()) if __name__ == "__main__": diff --git a/qemu/deps/win_serial/windows_support.py b/qemu/deps/win_serial/windows_support.py index 48fbe564f1f872c13c0bba01396ed075d2ea0dbd..9fb9fc4b49a7f8ef962525f5a9c939f2dc1f337e 100755 --- a/qemu/deps/win_serial/windows_support.py +++ b/qemu/deps/win_serial/windows_support.py @@ -42,9 +42,9 @@ class WinBufferedReadFile(object): frags = [] aux = 0 if self.verbose: - print "get %s, | bufs = %s [%s]" % (n, self._n, + print("get %s, | bufs = %s [%s]" % (n, self._n, ','.join(map(lambda x: str(len(x)), - self._bufs))) + self._bufs)))) while aux < n: frags.append(self._bufs.pop(0)) aux += len(frags[-1]) @@ -54,9 +54,9 @@ class WinBufferedReadFile(object): if len(rest) > 0: self._bufs.append(rest) if self.verbose: - print "return %s(%s), | bufs = %s [%s]" % (len(ret), n, self._n, + print("return %s(%s), | bufs = %s [%s]" % (len(ret), n, self._n, ','.join(map(lambda x: str(len(x)), - self._bufs))) + self._bufs)))) return ret try: # 4096 is the largest result viosdev will return right now. @@ -66,9 +66,9 @@ class WinBufferedReadFile(object): self._bufs.append(b[:nr]) self._n += nr if self.verbose: - print "read %s, err %s | bufs = %s [%s]" % (nr, err, self._n, + print("read %s, err %s | bufs = %s [%s]" % (nr, err, self._n, ','.join(map(lambda x: str(len(x)), - self._bufs))) + self._bufs)))) except: pass # Never Reached diff --git a/qemu/deps/windows_ga_install/get_package.py b/qemu/deps/windows_ga_install/get_package.py index 3a95ec608fea7a22fa73af71cf534c367d1f7e74..04de8180483aa8da1f0bda16a75b74e38ac596cc 100644 --- a/qemu/deps/windows_ga_install/get_package.py +++ b/qemu/deps/windows_ga_install/get_package.py @@ -70,7 +70,7 @@ class GuestAgentPkg(object): if status: raise Exception("the download from %s didn't run successfully" % url) - print ("\033[32m %s download successfully\033[0m" % url) + print("\033[32m %s download successfully\033[0m" % url) def parse_params(program):