import print_function to use print as function in python2

Summary: in python3, print becomes a function, import print_fuction to use in python 2.(ran fix_print_with_import)

Reviewed By: lisroach, quark-zju, sfilipco

Differential Revision: D19588356

fbshipit-source-id: b7cf519058ae3909ba7813618719bbd09800e73a
This commit is contained in:
Genevieve Helsel 2020-01-28 13:56:02 -08:00 committed by Facebook Github Bot
parent ed3a2b2247
commit e0fac9b23c
2 changed files with 23 additions and 16 deletions

View File

@ -1,3 +1,10 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import print_function
import os
import random
import sys
@ -14,7 +21,7 @@ def waithook(ui, repo, **kwargs):
repo.localvfs.write("hookrunning", "")
while not repo.localvfs.exists("flag"):
if time.time() - start > 20:
print >>sys.stderr, "ERROR: Timeout waiting for .hg/flag"
print("ERROR: Timeout waiting for .hg/flag", file=sys.stderr)
repo.localvfs.unlink("hookrunning")
return True
time.sleep(0.05)

View File

@ -1,12 +1,13 @@
#!/usr/bin/env python2
# stresstest-atomicreplace.py - test interrupting threading.Condition
#
# Copyright 2018 Facebook, Inc.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
#
# GNU General Public License version 2.
# This stress test checks if the replace logic in Mercurial is really atomic
from __future__ import print_function
import argparse
import os
import random
@ -28,14 +29,13 @@ def run_stress_test(n, binary, kill_median, kill_half_width):
py_filename = filename.replace("\\", "\\\\")
min_sleep = (kill_median - kill_half_width) / 1000.0
max_sleep = (kill_median + kill_half_width) / 1000.0
print "Will run (file content changes between iterations):"
print " ", CMD % (binary, py_filename, content)
print "for %i times and kill each run after unform(%f..%f) s" % (
n,
min_sleep,
max_sleep,
print("Will run (file content changes between iterations):")
print(" ", CMD % (binary, py_filename, content))
print(
"for %i times and kill each run after unform(%f..%f) s"
% (n, min_sleep, max_sleep)
)
print "Will check the existense of %s after each run\n" % filename
print("Will check the existense of %s after each run\n" % filename)
try:
# let's create a file upfront
open(filename, "w").close()
@ -46,9 +46,9 @@ def run_stress_test(n, binary, kill_median, kill_half_width):
time.sleep(tosleep)
proc.kill()
if not os.path.exists(filename):
print u"ALARM! Iteration %i failed. File not found. Slept: %fs" % (
p,
tosleep,
print(
u"ALARM! Iteration %i failed. File not found. Slept: %fs"
% (p, tosleep)
)
finally:
shutil.rmtree(tempdir)