def broadcastTable(fileName): """ Sends a table via SAMP. Parameters ---------- fileName : str Name of sky model file to broadcast """ from astropy.vo.samp import SAMPHubServer, SAMPIntegratedClient, SAMPHubError import urlparse client = SAMPIntegratedClient() client.connect() params = {} params["url"] = urlparse.urljoin('file:', os.path.abspath(fileName)) params["name"] = "LSMTool sky model" message = {} message["samp.mtype"] = "table.load.votable" message["samp.params"] = params # Send message client.call_all('lsmtool', message) # Disconnect from the SAMP hub client.disconnect()
def getSampConnect(self): ''' Get a SAMP listening client connection. ''' # Get a SAMP client client = SAMPIntegratedClient() client.connect() r = Receiver(client) return client
def SAMP_send_fits(filename,longname): client = SAMPIntegratedClient() client.connect() params = {} params["url"] = 'file://'+os.getcwd()+'/'+filename params["name"] = longname message = {} message["samp.mtype"] = "image.load.fits" message["samp.params"] = params client.notify_all(message) client.disconnect()
def SAMP_conn(): """a context manager to give the controlled block a SAMP connection. The program will disconnect as the controlled block is exited. """ client = SAMPIntegratedClient(name="serialquery", description="A serial SCS querier.") client.connect() try: yield client finally: client.disconnect()
def connection(client_name="pyvo client", description="A generic PyVO client", **kwargs): """ a context manager to give the controlled block a SAMP connection. The program will disconnect as the controlled block is exited. """ client = SAMPIntegratedClient(name=client_name, description=description, **kwargs) client.connect() try: yield client finally: client.disconnect()
def capCommand(self, *args, **kwargs): self.cli = SAMPIntegratedClient() self.cli.connect() self.r = self.Receiver(self.cli) self.dlg.label.setText("Binding methods") map(self.bindSamp,["qgis.message","qgis.load.vectorlayer","qgis.script", "table.load.votable"]) while self.connectionState: self.dlg.label.setText("starting") self.r.received = False while not self.r.received and self.connectionState: self.dlg.label.setText("waiting") time.sleep(2) self.dlg.label.setText("Command recieved") # self.cli.disconnect() if self.r.mtype == 'qgis.message': self.dlg.label.setText('Message: ' + self.r.params['script']) elif self.r.mtype == 'qgis.load.vectorlayer': self.dlg.label.setText('loading') self.mLoadVectorLayer(self.r.params['url'], self.r.params['name']) self.dlg.label.setText('done') elif self.r.mtype == 'qgis.script': self.dlg.label.setText('Exec: ' + self.r.params['script']) exec(self.r.params['script']) elif self.r.mtype == 'table.load.votable': #url, table-id, name self.dlg.label.setText('Votable url: '+self.r.params['url']) vot = Table.read(self.r.params['url']) # self.dlg.label.setText(str(len(vot)) # self.dlg.label.setText('table captured') # vot.show_in_browser(jsviewer=True) #should open table in a browser destination=tempfile.mkdtemp() # destination+='/vot.shp' destination+='/vot.geojson' # destination='/home/mminin/Documents/temp/shp/crism01.shp' self.dlg.label.setText('converting to geojson') # self.convertVOTtoSHP(vot, destination) self.convertVOTtoGEOJSON(vot, destination) self.dlg.label.setText('loading to map') # if self.r.params self.mLoadVectorLayer(destination, self.r.params['name']) self.dlg.label.setText('loaded') time.sleep(5) time.sleep(2) self.dlg.label.setText("slept") self.cli.disconnect() self.dlg.label.setText("Disconnected") return
def __init__(self): self._client = SAMPIntegratedClient()
layerTimeStamp = layerInfo['timestamp'] layers.append( LayerHandler(client, layerTimeStamp, observatory, instrument, detector, measurement, cutout)) handler = VSOHandler(client, start, end, timestamp, cadence, layers) return handler # The next cell connects to an active Hub (see http://docs.astropy.org/en/stable/vo/samp/example_table_image.html) # In[ ]: client = SAMPIntegratedClient() client.connect() r = Receiver(client) client.bind_receive_call("jhv.vso.load", r.receive_call) client.bind_receive_notification("jhv.vso.load", r.receive_notification) # ### Downloading the data # When a message is sent over SAMP, run the following to create a new Handler with the parameters given over SAMP. # # A Handler object named handler will be created which offers several utility methods to create a VSOQuery and download the data. # * __handler.createQuerySingleResult()__ # Creates a VSO-Query to only retrieve the currently show images in JHelioviewer for each active Layer # * __handler.createQuery()__ # Creates a VSO-Query for the complete timespan visible in JHelioviewer # * __handler.showQuery()__
def __init__(self, client): self.client = SAMPIntegratedClient() self.received = False
if len(sys.argv) < 2: os.system(folder + "/pipe.py") sys.exit(1) if 'web' not in sys.argv[1]: os.system(folder + "/pipe.py " + " ".join(sys.argv[2:])) sys.exit(1) import time from astropy.vo.samp import SAMPIntegratedClient from astropy.table import Table import websocket import webbrowser # Instantiate the client and connect to the hub client = SAMPIntegratedClient(name="samp-ws bridge") client.connect() host = "127.0.0.1" port = "9000" if len(sys.argv) > 2: host = sys.argv[2] if len(sys.argv) > 3: port = int(sys.argv[3]) # Set up a receiver class class Receiver(object): def __init__(self, client):