本文整理汇总了Python中WatchmanInstance类的典型用法代码示例。如果您正苦于以下问题:Python WatchmanInstance类的具体用法?Python WatchmanInstance怎么用?Python WatchmanInstance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WatchmanInstance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runner
def runner():
global results_queue
global tests_queue
try:
# Start up a shared watchman instance for the tests.
inst = WatchmanInstance.Instance()
inst.start()
# Allow tests to locate this default instance
WatchmanInstance.setSharedInstance(inst)
except Exception as e:
print('This is going to suck:', e)
return
while True:
test = tests_queue.get()
try:
if test == 'terminate':
break
if Interrupt.wasInterrupted():
continue
try:
result = Result()
test.run(result)
results_queue.put(result)
except Exception as e:
print(e)
finally:
tests_queue.task_done()
inst.stop()
示例2: runTest
def runTest(self):
env = os.environ.copy()
env['WATCHMAN_SOCK'] = WatchmanInstance.getSharedInstance().getSockPath()
dotted = os.path.normpath(self.id()).replace(os.sep, '.').replace(
'tests.integration.', '').replace('.php', '')
env['TMPDIR'] = os.path.join(tempfile.tempdir, dotted)
os.mkdir(env['TMPDIR'])
env['TMP'] = env['TMPDIR']
env['TEMP'] = env['TMPDIR']
env['IN_PYTHON_HARNESS'] = '1'
proc = subprocess.Popen(
self.getCommandArgs(),
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(stdout, stderr) = proc.communicate()
status = proc.poll()
if status == -signal.SIGINT:
Interrupt.setInterrupted()
self.fail('Interrupted by SIGINT')
return
if status != 0:
self.fail("Exit status %d\n%s\n%s\n" %
(status, stdout.decode('utf-8'), stderr.decode('utf-8')))
return
self.assertTrue(True, self.jsfile)
示例3: runTest
def runTest(self):
env = os.environ.copy()
env['WATCHMAN_SOCK'] = WatchmanInstance.getSharedInstance().getSockPath()
dotted = os.path.normpath(self.id()).replace(os.sep, '.').replace(
'tests.integration.', '').replace('.php', '')
env['TMPDIR'] = os.path.join(TempDir.get_temp_dir().get_dir(), dotted)
os.mkdir(env['TMPDIR'])
# build the node module with npm
node_dir = os.path.join(env['TMPDIR'], 'fb-watchman')
shutil.copytree(os.path.join(WATCHMAN_SRC_DIR, 'node'), node_dir)
subprocess.check_call(['npm', 'install'], cwd=node_dir)
env['TMP'] = env['TMPDIR']
env['TEMP'] = env['TMPDIR']
env['IN_PYTHON_HARNESS'] = '1'
env['NODE_PATH'] = '%s:%s' % (env['TMPDIR'], env.get('NODE_PATH', ''))
proc = subprocess.Popen(
self.getCommandArgs(),
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(stdout, stderr) = proc.communicate()
status = proc.poll()
if status == -signal.SIGINT:
Interrupt.setInterrupted()
self.fail('Interrupted by SIGINT')
return
if status != 0:
self.fail("Exit status %d\n%s\n%s\n" %
(status, stdout.decode('utf-8'), stderr.decode('utf-8')))
return
self.assertTrue(True, self.getCommandArgs())
示例4: runTest
def runTest(self):
env = os.environ.copy()
env["WATCHMAN_SOCK"] = WatchmanInstance.getSharedInstance().getSockPath()
env["TMPDIR"] = self.tempdir
# build the node module with npm
node_dir = os.path.join(env["TMPDIR"], "fb-watchman")
shutil.copytree(os.path.join(WATCHMAN_SRC_DIR, "node"), node_dir)
subprocess.check_call(["npm", "install"], cwd=node_dir)
env["TMP"] = env["TMPDIR"]
env["TEMP"] = env["TMPDIR"]
env["IN_PYTHON_HARNESS"] = "1"
env["NODE_PATH"] = "%s:%s" % (env["TMPDIR"], env.get("NODE_PATH", ""))
proc = subprocess.Popen(
self.getCommandArgs(),
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
(stdout, stderr) = proc.communicate()
status = proc.poll()
if status == -signal.SIGINT:
Interrupt.setInterrupted()
self.fail("Interrupted by SIGINT")
return
if status != 0:
self.fail(
"Exit status %d\n%s\n%s\n"
% (status, stdout.decode("utf-8"), stderr.decode("utf-8"))
)
return
self.assertTrue(True, self.getCommandArgs())
示例5: getClient
def getClient(self):
if not hasattr(self, 'client'):
self.client = pywatchman.client(
transport=self.transport,
sendEncoding=self.encoding,
recvEncoding=self.encoding,
sockpath=WatchmanInstance.getSharedInstance().getSockPath())
return self.client
示例6: dumpLogs
def dumpLogs(self):
''' used in travis CI to show the hopefully relevant log snippets '''
inst = WatchmanInstance.getSharedInstance()
def tail(logstr, n):
lines = logstr.split('\n')[-n:]
return '\n'.join(lines)
print(self.getLogSample())
示例7: getClient
def getClient(self):
if not hasattr(self, 'client'):
self.client = pywatchman.client(
# ASAN-enabled builds can be slower enough that we hit timeouts
# with the default of 1 second
timeout=3.0,
transport=self.transport,
sendEncoding=self.encoding,
recvEncoding=self.encoding,
sockpath=WatchmanInstance.getSharedInstance().getSockPath())
return self.client
示例8: getLogSample
def getLogSample(self):
''' used in CI to show the hopefully relevant log snippets '''
inst = WatchmanInstance.getSharedInstance()
def tail(logstr, n):
lines = logstr.split('\n')[-n:]
return '\n'.join(lines)
return '\n'.join([
'CLI logs',
tail(inst.getCLILogContents(), 500),
'Server logs',
tail(inst.getServerLogContents(), 500),
])
示例9: getClient
def getClient(self, inst=None, replace_cached=False, no_cache=False):
if inst or not hasattr(self, "client") or no_cache:
client = pywatchman.client(
timeout=self.socketTimeout,
transport=self.transport,
sendEncoding=self.encoding,
recvEncoding=self.encoding,
sockpath=(inst or WatchmanInstance.getSharedInstance()).getSockPath(),
)
if (not inst or replace_cached) and not no_cache:
# only cache the client if it points to the shared instance
self.client = client
self.addCleanup(lambda: self.__clearClient())
return client
return self.client
示例10: getLogSample
def getLogSample(self):
""" used in CI to show the hopefully relevant log snippets """
inst = WatchmanInstance.getSharedInstance()
def tail(logstr, n):
lines = logstr.split("\n")[-n:]
return "\n".join(lines)
return "\n".join(
[
"CLI logs",
tail(inst.getCLILogContents(), 500),
"Server logs",
tail(inst.getServerLogContents(), 500),
]
)
示例11: getClient
def getClient(self, inst=None):
if inst or not hasattr(self, 'client'):
client = pywatchman.client(
# ASAN-enabled builds can be slower enough that we hit timeouts
# with the default of 1 second
timeout=3.0,
transport=self.transport,
sendEncoding=self.encoding,
recvEncoding=self.encoding,
sockpath=(inst or
WatchmanInstance.getSharedInstance()).getSockPath())
if not inst:
# only cache the client if it points to the shared instance
self.client = client
return client
return self.client
示例12: spawnWatchmanWait
def spawnWatchmanWait(self, cmdArgs):
wait_script = os.environ.get("WATCHMAN_WAIT_PATH")
if wait_script:
args = [wait_script]
else:
args = [
sys.executable,
os.path.join(os.environ["WATCHMAN_PYTHON_BIN"], "watchman-wait"),
]
args.extend(cmdArgs)
env = os.environ.copy()
sock_path = WatchmanInstance.getSharedInstance().getSockPath()
env["WATCHMAN_SOCK"] = sock_path
env["PYTHONPATH"] = env["PYWATCHMAN_PATH"]
return subprocess.Popen(
args, env=env, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
示例13: test_cppclient
def test_cppclient(self):
env = os.environ.copy()
env["WATCHMAN_SOCK"] = WatchmanInstance.getSharedInstance().getSockPath()
proc = subprocess.Popen(
TEST_BINARY, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
(stdout, stderr) = proc.communicate()
status = proc.poll()
if status == -signal.SIGINT:
Interrupt.setInterrupted()
self.fail("Interrupted by SIGINT")
return
if status != 0:
self.fail(
"Exit status %d\n%s\n%s\n"
% (status, stdout.decode("utf-8"), stderr.decode("utf-8"))
)
return
self.assertTrue(True, TEST_BINARY)
示例14: hg
def hg(self, args=None, cwd=None):
env = dict(os.environ)
env['HGPLAIN'] = '1'
env['HGUSER'] = 'John Smith <[email protected]>'
env['NOSCMLOG'] = '1' # disable some instrumentation at FB
env['WATCHMAN_SOCK'] = \
WatchmanInstance.getSharedInstance().getSockPath()
p = subprocess.Popen(
# we force the extension on. This is a soft error for
# mercurial if it is not available, so we also employ
# the skipIfNoFSMonitor() test above to make sure the
# environment is sane.
['hg', '--config', 'extensions.fsmonitor='] + args,
env=env,
cwd=cwd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = p.communicate()
if p.returncode != 0:
raise Exception("hg %r failed: %s, %s" % (args, out, err))
return out, err
示例15: hg
def hg(self, args=None, cwd=None):
env = dict(os.environ)
env["HGPLAIN"] = "1"
env["HGUSER"] = "John Smith <[email protected]>"
env["NOSCMLOG"] = "1" # disable some instrumentation at FB
env["WATCHMAN_SOCK"] = WatchmanInstance.getSharedInstance().getSockPath()
p = subprocess.Popen(
# we force the extension on. This is a soft error for
# mercurial if it is not available, so we also employ
# the skipIfNoFSMonitor() test above to make sure the
# environment is sane.
[env.get("EDEN_HG_BINARY", "hg"), "--config", "extensions.fsmonitor="]
+ args,
env=env,
cwd=cwd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
out, err = p.communicate()
if p.returncode != 0:
raise Exception("hg %r failed: %s, %s" % (args, out, err))
return out, err