• robertiii

    I am curious why no log was left behind...I even added a startup script to log problems and it always left nothing.

    posted in Pythonista read more
  • robertiii

    I feel like an idiot. The variable set and setup was supposed to be one. It was running continually in the thread and causing a crash I assume because of taking too much space. Changed the variables to the same and no problem.

    posted in Pythonista read more
  • robertiii

    Weirdest part is the fact that there is no error log. It kills Pythonista with no log.

    posted in Pythonista read more
  • robertiii

    So pardon my ignorance. I have a script with us and it works great....until it crashes the entire app. Hahaha.

    from pyftpdlib.authorizers import DummyAuthorizer
    from pyftpdlib.handlers import FTPHandler
    from pyftpdlib.servers import FTPServer
    import threading
    import os
    import time
    import ui
    
    port = 2121
    
    def getLocalIP():
        import socket
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        try:
            s.connect(('google.com', 80))
            ip = s.getsockname()[0]
            s.close()
        except:
            ip = 'N/A'
        return ip
    
    def imageSetter(valid_extensions=('jpg','jpeg','png')):
        while True:
            currentImage = ''
            set = False
            dirpath = os.path.expanduser('~/Documents/tetherShootPhotos')
            try:
                valid_files = [os.path.join(dirpath, filename) for filename in os.listdir(dirpath)]
                valid_files = [f for f in valid_files if '.' in f and f.rsplit('.',1)[-1] in valid_extensions and os.path.isfile(f)]
    
                if not valid_files:
                    raise ValueError("No valid images in %s" % dirpath)
        
                imageLink = max(valid_files, key=os.path.getmtime)
                
                if imageLink != currentImage:
                    newImage = ui.Image.named(imageLink)
                    currentImage = imageLink
                    v['image'].image = newImage
                    v['ipAddress'].hidden = True
                    v['connectAt'].hidden = True
                    set = False
            except:
                if set == False:
                    set = True
                    newImage = ui.Image.named('tetherShoot.png')
                    v['image'].image = newImage
                    v['ipAddress'].hidden = False
                    v['connectAt'].hidden = False
                    ipAddr = getLocalIP()+':'+str(port)
                    v['ipAddress'].text = ipAddr
            time.sleep(1)
    
    def main():
        authorizer = DummyAuthorizer()
        authorizer.add_anonymous(os.path.expanduser('~/Documents/tetherShootPhotos'), perm='elradfmwM')
        handler = FTPHandler
        handler.authorizer = authorizer
        server = FTPServer(('0.0.0.0', port), handler)
        t = threading.Thread(target=server.serve_forever)
        t.start()
        try:
            setup = False
            while True: pass
        except KeyboardInterrupt:
            server.close_all()
    
    if __name__ == '__main__':
        import ui 
        v = ui.load_view()
        v['ipAddress'].hidden   = True
        v['connectAt'].hidden = True
        v['image'].content_mode = ui.CONTENT_SCALE_ASPECT_FIT
        imageUpdater = threading.Thread(target=imageSetter)
        imageUpdater.start()
        v.present('fullscreen',hide_title_bar=True)
        main()
    

    posted in Pythonista read more
  • robertiii

    Any idea on how to go to workflow and return a variable using the Xcode template? I am at a total loss.

    posted in Pythonista read more
  • robertiii

    I can get the ui to change for a device getting connected, but not when I turn the device off. How can I detect that the device has been turned off and is no longer connected to the iPad

    posted in Pythonista read more
  • robertiii

    Thank you!!!!!!!

    posted in Pythonista read more
  • robertiii

    Strangely enough it does work if called from a button action....

    posted in Pythonista read more
  • robertiii

    When I try to use the sendData function, I get an error stating that nonObject has write_characteristic_value.

    class bellRinger (object):
        def __init__(self):
            self.peripheral = None
            self.characteristic = None
    
        def did_discover_peripheral(self, p):
            if p.name and 'School Bell' in p.name and not self.peripheral:  #Change Name Here
                self.peripheral = p
                peripheral = p
                cb.connect_peripheral(p)
    
        def did_connect_peripheral(self, p):
            p.discover_services()
    
        def did_fail_to_connect_peripheral(self, p, error):
            print('Failed to Connect')
            
        def did_disconnect_peripheral(self, p, error):
            self.peripheral = None
    
        def did_discover_services(self, p, error):
            for s in p.services:
                if s.uuid == 'FFE0':
                    p.discover_characteristics(s)
    
        def did_discover_characteristics(self, s, error):
            for c in s.characteristics:
                if c.uuid == 'FFE1':
                    self.characteristic = c
                    characteristic = c
                    self.peripheral.set_notify_value(c, True)
    
        def did_update_value(self, c, error):
            print('Got Something',c.value)
        
        def sendData():
            c = self.characteristic
            self.peripheral.write_characteristic_value(c, 'ring/', True)
    
    mngr = bellRinger()
    cb.set_central_delegate(mngr)
    cb.scan_for_peripherals()
    mngr.sendData()
    

    posted in Pythonista read more
  • robertiii

    I have a fairly large project. I would like to split the files up. I would like to split it as follows. A file for custom view classes. An individual file for each tableview. A file for the main document (obviously). If it is possible a file for the button actions.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!