MCPcopy Index your code
hub / github.com/nodejs/node / push_file

Method push_file

deps/v8/tools/testrunner/local/android.py:84–123  ·  view source on GitHub ↗

Push a single file to the device (cached). Args: host_dir: Absolute parent directory of the file to push. file_name: Name of the file to push. target_rel: Parent directory of the target location on the device (relative to the device's base dir for testing). ski

(self, host_dir, file_name, target_rel='.',
                skip_if_missing=False)

Source from the content-addressed store, hash-verified

82 self.device.RemovePath(DEVICE_DIR, force=True, recursive=True)
83
84 def push_file(self, host_dir, file_name, target_rel='.',
85 skip_if_missing=False):
86 """Push a single file to the device (cached).
87
88 Args:
89 host_dir: Absolute parent directory of the file to push.
90 file_name: Name of the file to push.
91 target_rel: Parent directory of the target location on the device
92 (relative to the device's base dir for testing).
93 skip_if_missing: Keeps silent about missing files when set. Otherwise logs
94 error.
95 """
96 # TODO(sergiyb): Implement this method using self.device.PushChangedFiles to
97 # avoid accessing low-level self.device.adb.
98 file_on_host = os.path.join(host_dir, file_name)
99
100 # Only push files not yet pushed in one execution.
101 if file_on_host in self.pushed:
102 return
103
104 file_on_device_tmp = os.path.join(DEVICE_DIR, '_tmp_', file_name)
105 file_on_device = os.path.join(DEVICE_DIR, target_rel, file_name)
106 folder_on_device = os.path.dirname(file_on_device)
107
108 # Only attempt to push files that exist.
109 if not os.path.exists(file_on_host):
110 if not skip_if_missing:
111 logging.critical('Missing file on host: %s' % file_on_host)
112 return
113
114 # Work-around for 'text file busy' errors. Push the files to a temporary
115 # location and then copy them with a shell command.
116 output = self.device.adb.Push(file_on_host, file_on_device_tmp)
117 # Success looks like this: '3035 KB/s (12512056 bytes in 4.025s)'.
118 # Errors look like this: 'failed to copy ... '.
119 if output and not re.search('^[0-9]', output.splitlines()[-1]):
120 logging.critical('PUSH FAILED: ' + output)
121 self.device.adb.Shell('mkdir -p %s' % folder_on_device)
122 self.device.adb.Shell('cp %s %s' % (file_on_device_tmp, file_on_device))
123 self.pushed.add(file_on_host)
124
125 def push_files_rec(self, host_dir, target_rel='.'):
126 """As above, but push the whole directory tree under host_dir."""

Callers 4

push_files_recMethod · 0.95
push_executableMethod · 0.95
PreTestsMethod · 0.80
push_test_resourcesMethod · 0.80

Calls 5

addMethod · 0.65
joinMethod · 0.45
existsMethod · 0.45
searchMethod · 0.45
splitlinesMethod · 0.45

Tested by

no test coverage detected