Exemplo n.º 1
0
 def _repo_dir(self):
     if "://" in self.attributes['repo']:
         repo_dir = clone_to_dir(self.attributes['repo'], self.attributes['rev'])
         io.debug(_("registering {} for deletion on exit").format(repo_dir))
         at_exit(rmtree, repo_dir)
     else:
         repo_dir = get_local_repo_path(self.node.repo.path, self.attributes['repo'])
     return repo_dir
Exemplo n.º 2
0
 def _repo_dir(self):
     if "://" in self.attributes['repo']:
         repo_dir = clone_to_dir(self.attributes['repo'], self.attributes['rev'])
         io.debug(_("registering {} for deletion on exit").format(repo_dir))
         at_exit(rmtree, repo_dir)
     else:
         repo_dir = get_local_repo_path(self.node.repo.path, self.attributes['repo'])
     return repo_dir
Exemplo n.º 3
0
 def _repo_dir(self):
     if "://" in self.attributes['repo']:
         repo_dir, remove_dir = clone_to_dir(self.attributes['repo'],
                                             self.attributes['rev'])
         if remove_dir is not None:
             io.debug(
                 _("registering {} for deletion on exit").format(
                     remove_dir))
             at_exit(rmtree, remove_dir, ignore_errors=True)
     else:
         repo_dir = get_local_repo_path(self.node.repo.path,
                                        self.attributes['repo'])
     return repo_dir
"""

from vizier.api.client.base import VizierApiClient
from vizier.api.client.datastore.base import DatastoreClient
from vizier.api.routes.base import UrlFactory
from vizier.api.routes.datastore import DatastoreClientUrlFactory
from vizier.datastore.dataset import DatasetColumn, DatasetRow

from atexit import register as at_exit

URLS = UrlFactory(base_url='http://localhost:5000/vizier-db/api/v1')

api = VizierApiClient(URLS)
PROJECT_ID = api.create_project({"name": "Test Client Datastore"}).identifier

at_exit(api.delete_project, PROJECT_ID)

# We're just doing some unit testing on the fields specific to DatastoreClient, so
# ignore complaints about instantiating an abstract class
store = DatastoreClient(  # type: ignore[abstract]
    urls=DatastoreClientUrlFactory(urls=URLS, project_id=PROJECT_ID))

ds = store.create_dataset(columns=[
    DatasetColumn(identifier=0, name='Name'),
    DatasetColumn(identifier=1, name='Age', data_type="int")
],
                          rows=[
                              DatasetRow(identifier=0, values=['Alice', 32]),
                              DatasetRow(identifier=1, values=['Bob', 23])
                          ],
                          properties={"example_property": "foo"})
Exemplo n.º 5
0
def start_server():
    blender_paths = ['/Applications/blender.app/Contents/MacOS/blender',
                     '/Applications/Blender.app/Contents/MacOS/blender']
    base = mkdtemp()
    with open(join(base, 'server.py'), 'w+') as f: f.write(SERVER_SOURCE)
    blender_path = next(iter(filter(isfile, blender_paths)), 'blender')
    command = [blender_path, '-b', '-P', join(base, 'server.py')]
    Popen(command, stdout=open(devnull, 'w'), stderr=open(devnull, 'w'))
    while not exists(join(base, 'lock.txt')): sleep(.001)
    with open(join(base, 'port.txt')) as f: port = f.read()
    rmtree(base)
    return ServerProxy("http://localhost:%s/" % port, allow_none=True)

server = start_server()
at_exit(server.shut_down)

class Monitor(object):
    def __init__(self, destructor):
        self.destructor = destructor

    def __del__(self):
        try: self.destructor()
        except: pass

resource_types = {}
resources = WeakValueDictionary()
resource_ids = WeakKeyDictionary()
resource_monitors = WeakKeyDictionary()

def reference(resource):
Exemplo n.º 6
0
    base = mkdtemp()
    with open(join(base, 'server.py'), 'w+') as f:
        f.write(SERVER_SOURCE)
    blender_path = next(iter(filter(isfile, blender_paths)), 'blender')
    command = [blender_path, '-b', '-P', join(base, 'server.py')]
    Popen(command, stdout=open(devnull, 'w'), stderr=open(devnull, 'w'))
    while not exists(join(base, 'lock.txt')):
        sleep(.001)
    with open(join(base, 'port.txt')) as f:
        port = f.read()
    rmtree(base)
    return ServerProxy("http://localhost:%s/" % port, allow_none=True)


server = start_server()
at_exit(server.shut_down)


class Monitor(object):
    def __init__(self, destructor):
        self.destructor = destructor

    def __del__(self):
        try:
            self.destructor()
        except:
            pass


resource_types = {}
resources = WeakValueDictionary()