def bead(self, timestamp): tmp = self.new_temp_dir() ws = Workspace(tmp / 'ws') ws.create('bead-uuid') bead_archive = tmp / 'bead.zip' ws.pack(bead_archive, timestamp, comment='bead for a shared box') return bead_archive
def bead(self, timestamp): tmp = self.new_temp_dir() ws = Workspace(tmp / 'ws') ws.create('a bead kind') bead_archive = tmp / 'bead.zip' ws.pack(bead_archive, timestamp, comment='bead for a shared box') return bead_archive
def make_bead(timestamp): with TempDir() as tempdir_obj: workspace_dir = os.path.join(tempdir_obj.path, bead_name) ws = Workspace(workspace_dir) ws.create(bead_uuid) sentinel_file = ws.directory / 'sentinel-{}'.format(timestamp) tech.fs.write_file(sentinel_file, timestamp) box.store(ws, timestamp) tech.fs.rmtree(workspace_dir)
def make_bead(freeze_time): with TempDir() as tempdir_obj: workspace_dir = os.path.join(tempdir_obj.path, bead_name) ws = Workspace(workspace_dir) ws.create(bead_kind) sentinel_file = ws.directory / f'sentinel-{freeze_time}' tech.fs.write_file(sentinel_file, freeze_time) tech.fs.write_file(ws.directory / 'output/README', freeze_time) box.store(ws, freeze_time) tech.fs.rmtree(workspace_dir)
def make_bead(timestamp): with TempDir() as tempdir_obj: workspace_dir = os.path.join(tempdir_obj.path, bead_name) ws = Workspace(workspace_dir) ws.create(bead_kind) sentinel_file = ws.directory / f'sentinel-{timestamp}' tech.fs.write_file(sentinel_file, timestamp) tech.fs.write_file(ws.directory / 'output/README', timestamp) box.store(ws, timestamp) tech.fs.rmtree(workspace_dir)
def make_bead(timestamp): with TempDir() as tempdir_obj: workspace_dir = os.path.join(tempdir_obj.path, bead_name) ws = Workspace(workspace_dir) ws.create(bead_kind) sentinel_file = ws.directory / 'sentinel-{}'.format(timestamp) tech.fs.write_file(sentinel_file, timestamp) tech.fs.write_file(ws.directory / 'output/README', timestamp) box.store(ws, timestamp) tech.fs.rmtree(workspace_dir)
def hacked_bead(self, robot, beads): hacked_bead_path = self.new_temp_dir() / 'hacked_bead.zip' workspace_dir = self.new_temp_dir() / 'hacked_bead' ws = Workspace(workspace_dir) ws.create('hacked-kind') tech.fs.write_file(ws.directory / 'code', 'code') tech.fs.write_file(ws.directory / 'output/README', 'README') ws.pack(hacked_bead_path, TS1, comment='hacked bead') with zipfile.ZipFile(hacked_bead_path, 'a') as z: with warnings.catch_warnings(): warnings.simplefilter('ignore') # this would cause a warning from zipfile for duplicate # name in zip file (which is perfectly valid, though hacky) z.writestr(layouts.Archive.CODE / 'code', 'HACKED') z.writestr(layouts.Archive.DATA / 'README', 'HACKED') return hacked_bead_path