How to use the pixiedust.utils.shellAccess.ShellAccess function in pixiedust

To help you get started, we’ve selected a few pixiedust examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pixiedust / pixiedust_node / pixiedust_node / node.py View on Github external
if line:
                    obj = json.loads(line)
                    # if it does and is a pixiedust object
                    if obj and isinstance(obj, dict) and obj['_pixiedust']:
                        if obj['type'] == 'display':
                            pdf = pandas.DataFrame(obj['data'])
                            ShellAccess.pdf = pdf
                            display(pdf)
                        elif obj['type'] == 'print':
                            print(json.dumps(obj['data']))
                        elif obj['type'] == 'store':
                            print('!!! Warning: store is now deprecated - Node.js global variables are automatically propagated to Python !!!')
                            variable = 'pdf'
                            if 'variable' in obj:
                                variable = obj['variable']
                            ShellAccess[variable] = pandas.DataFrame(obj['data'])
                        elif obj['type'] == 'html':
                            IPython.display.display(IPython.display.HTML(obj['data']))
                        elif obj['type'] == 'image':
                            IPython.display.display(IPython.display.HTML('<img src="{0}">'.format(obj['data'])))
                        elif obj['type'] == 'variable':
                            ShellAccess[obj['key']] = obj['value']
                            if self.vw:
                                self.vw.setCache(obj['key'], obj['value'])
                    else:
                        print(line)
            except Exception as e:
                # output the original line when we don't have JSON
                line = line.strip()
                if len(line) &gt; 0:
                    print(line)
github pixiedust / pixiedust_node / pixiedust_node / nodestdreader.py View on Github external
try:

                # if it does and is a pixiedust object
                if obj and obj['_pixiedust']: 
                    if obj['type'] == 'display':
                        pdf = pandas.DataFrame(obj['data'])
                        ShellAccess.pdf = pdf
                        display(pdf)
                    elif obj['type'] == 'print':
                        print(json.dumps(obj['data']))
                    elif obj['type'] == 'store':
                        variable = 'pdf'
                        if 'variable' in obj:
                            variable = obj['variable']
                        ShellAccess[variable] = pandas.DataFrame(obj['data'])
                    elif obj['type'] == 'html':
                        IPython.display.display(IPython.display.HTML(obj['data']))
                    elif obj['type'] == 'image':
                        IPython.display.display(IPython.display.HTML('<img src="{0}">'.format(obj['data'])))
  
            except Exception as e:
                print(line)
                print(e)