• Tizzy

    @ccc @omz I’m also curious how that’s going with this week’s Mac catalyst updates etc...?

    posted in General Discussion read more
  • Tizzy

    I hadn't used stash in a while as well, trying to launch it made this:

    Traceback (most recent call last):
      File "/private/var/mobile/Containers/Shared/AppGroup/FC7E6E85-01F7-47E5-861F-A7ACA8D91116/Pythonista3/Documents/launch_stash.py", line 28, in <module>
        from stash import stash
      File "/private/var/mobile/Containers/Shared/AppGroup/FC7E6E85-01F7-47E5-861F-A7ACA8D91116/Pythonista3/Documents/site-packages/stash/stash.py", line 20, in <module>
        from system.shcommon import IN_PYTHONISTA, ON_IPAD
      File "/private/var/mobile/Containers/Shared/AppGroup/FC7E6E85-01F7-47E5-861F-A7ACA8D91116/Pythonista3/Documents/site-packages/stash/system/shcommon.py", line 29, in <module>
      File "/var/containers/Bundle/Application/32DB935B-D704-4D48-BBE9-99A076A0D0AB/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/ctypes/__init__.py", line 364, in __init__
        self._handle = _dlopen(self._name, mode)
    OSError: dlopen(/var/containers/Bundle/Application/32DB935B-D704-4D48-BBE9-99A076A0D0AB/Pythonista3.app/Frameworks/PythonistaKit.framework/PythonistaKit, 6): image not found

    Pythonista 301012 beta.

    posted in Pythonista read more
  • Tizzy

    @aronchi one more thing. You can add this script to your app extension for Pythonista. If you have a raw text file hosted via a server, if you go to it in safari and run this extension on it, it will ask you to name the file and then download that text. I think you might need to manually create a "Downloads" folder in documents.

    Disclaimer - I don't remember where I got this file. It might have been @ccc or @Webmaster4o or maybe @TutorialDoctor ...sorry!

    # coding: utf-8
    import requests
    import appex
    from console import alert, input_alert
    import os.path
    import os
    def main():
        if not appex.is_running_extension():
            alert("Error", "This script is intended to be run from the sharing extension.", "Exit", hide_cancel_button=True)
        url = appex.get_url()
        if not url:
            alert("ERROR", "No input URL found.  Execute this script from the sharing extension.", "Quit", hide_cancel_button=True) 
        root_path = "../../Documents/Downloads/"
        while True:
            filename = input_alert("Download File", "You have chosen to download file at URL:\n " + url + "\n\nEnter filename to save locally.  Press Cancel to abort.")
            filename = root_path+filename
            if os.path.exists(filename):
                if os.path.isfile(filename):
                    confirm = alert("Warning", "File %s exists.  Overwrite?" % filename, "Overwrite", "Change Filename", hide_cancel_button=True)
                    if confirm == 1:
                    alert("Critical Error.", "Path exists but is not a file.  Exiting.", "Exit", hide_cancel_button=True)
        r = requests.get(url)
        if r.status_code != 200:
            alert("Invalid HTTP Response: %d, Exiting." %r.status_code, "Exit", hide_cancel_button=True)
        confirm = alert("Confirm Download", "Text length: %d, Press OK to Save, Cancel to Quit" %len(r.text), "Save", "Cancel", hide_cancel_button=True)
        if confirm == 1:
            outfile = open(filename, "w")
            for line in r.text:
            alert("Success", "File Saved.", "Exit", hide_cancel_button=True)
    if __name__ == '__main__':

    posted in Pythonista read more
  • Tizzy

    Where are your 3 files stored?

    posted in Pythonista read more
  • Tizzy

    Hi. There's a couple ways you can do this.

    1.) Manually: Use Dropbox/some other tool to get the scripts on your iPad in any form. Copy the contents of each script, create a new script in Pythonista, name it as you'd like, and then paste the contents.

    2.) DropBox sync: Use the dropboxsync.py script found elsewhere on this forum. You need to setup a Dropbox developer account and get a token. (I've been using the same version of that script that isn't perfect and has some problems with case, if anybody else knows what the latest greatest version of that script is please chime in)

    3.) git / github : If you're familiar with using git/ github, you can create a repo in github. Then, install Stash (https://github.com/ywangd/stash), launch it, choose the directory and clone there using standard git commands.

    Let us know if you have any questions.

    posted in Pythonista read more
  • Tizzy

    @pacco Checking in, any word on proxies in Pythonista since we brought this up quite a while ago? Any Luck?

    posted in Pythonista read more
  • Tizzy

    Oops. You're completely correct. I forgot I had installed that separately, using StaSh, pip install rauth.


    posted in Pythonista read more
  • Tizzy

    At some point I started getting insecure platform warnings when requests was upgraded in Pythonista many many builds ago.

    posted in Pythonista read more
  • Tizzy

    import rauth does not work in beta 300015. I believe it worked in the previous build, although I'm not sure. It definitely does work in Pythonista 2.

    ImportError: No module named 'rauth'

    posted in Pythonista read more
  • Tizzy

    Thanks @omz @jonb @dgelessus that did the trick...

    Something to note: running through the levels in 0.1 increments, it appears the only actual discrete levels are 1.0,0.9,0.8, and 0.4, unless there are finer increments between 0.4 and 1.0 ....

    from objc_util import ObjCClass
    import time
    def toggle_flashlight():
        AVCaptureDevice = ObjCClass('AVCaptureDevice')
        device = AVCaptureDevice.defaultDeviceWithMediaType_('vide')
        if not device.hasTorch():
            raise RuntimeError('Device has no flashlight')
        mode = device.torchMode()
        if device.torchMode()>0:
            device.setTorchMode_((mode + 1) % 2)
            a =[1.0,0.9,0.8,0.7,0.6,0.5,0.4,0.3,0.2,0.1]
            for each in a:
                device.setTorchModeOnWithLevel_error_(each, None)
                print('level '+str(each))
            #device.setTorchModeOnWithLevel_error_(0.88, None)
        #device.setTorchModeOnWithLevel_error_(0.2, None)
    if __name__ == '__main__':

    posted in Pythonista read more
  • Tizzy

    @Phuket2 @JonB thanks for the feedback! Lots to think about..

    To start somewhere -

    • In order to make sure the total elapsed time always adds up I made it be a summation of each of the player elapsed times. This is probably cheating?
    • Also I got rid of some conditionals by making discrete active and inactive player objects.
    • Also added self.v.on_screen as the condition for the while loop.

    And I meant to ask, too - is it considered good practice to use UI objects as the main objects of your data structure like I did adding attributes onto them willy nilly?

    posted in Pythonista read more
  • Tizzy

    @Vertec @jonb @Webmaster4o @Phuket2 this is my go at it, what do you think?

    UPDATE: streamlined the code a little bit by making there be discreet "active" and "inactive" players, with a currentActivePlayer.otherPlayer attribute pointing to the other player to get rid of some unnecessary conditionals.

    import ui,time
    import bz2
    from base64 import b64decode
    #versions oldest - newest
    class clockster(object):
        def __init__(self):
            #_______PACKAGED UI ______
            compressedui = '''\
            pyui = bz2.decompress(b64decode(compressedui))
            v = ui.load_view_str(pyui.decode('utf-8'))
            self.v = v
            #_______END PACKAGED UI________
            #self.v = ui.load_view()
            self.startTime = time.time()
            self.gameBegun = False
            self.playerOne = self.v["playerOne"]
            self.playerTwo = self.v["playerTwo"]
            self.playerOne.timeLabel = self.v["playerOneTime"]
            self.playerTwo.timeLabel = self.v["playerTwoTime"]
            self.playerOne.totalTimeElapsed = 0
            self.playerTwo.totalTimeElapsed = 0 
            self.playerOne.latestTurnElapsed = 0
            self.playerTwo.latestTurnElapsed = 0
            self.playerOne.otherPlayer = self.playerTwo
            self.playerTwo.otherPlayer = self.playerOne
            self.currentActivePlayer = "NOBODY"
        def togglePlayer(self,sender):
            if self.currentActivePlayer == sender:
                print("no change....")
            elif self.currentActivePlayer == "NOBODY":
                print("this means THE GAME HAS BEGUN!")
                self.gameBegun = True
                self.startTime = time.time()
                self.currentActivePlayer = sender
                self.currentInactivePlayer = self.currentActivePlayer.otherPlayer
                self.lastTimeToggled = time.time()
                print('...first move by: ',sender.name)
                print('currentActivePlayer changing....')
                #cleaning up old active plyayer
                self.currentActivePlayer.totalTimeElapsed = self.currentActivePlayer.totalTimeElapsed+self.currentActivePlayer.latestTurnElapsed
                #new active/inactive player
                self.currentActivePlayer = sender
                self.currentInactivePlayer = sender.otherPlayer
                self.lastTimeToggled = time.time()
                print("player toggled to",sender.name)
        def switchClockOnForSelectedPlayer(self):
            self.currentActivePlayer.latestTurnElapsed= time.time()-self.lastTimeToggled
            self.currentActivePlayer.timeToDisplay= self.currentActivePlayer.totalTimeElapsed + self.currentActivePlayer.latestTurnElapsed
            self.currentActivePlayer.timeLabel.text = str(round(self.currentActivePlayer.timeToDisplay))
            self.totalElapsedTimeBySumming = self.currentActivePlayer.timeToDisplay + self.currentInactivePlayer.totalTimeElapsed
        def mainLoop(self):
            while self.v.on_screen:
                if self.gameBegun is True:
                    timeElapsed = round(time.time()-self.startTime,0)
                    #self.v["totalTime"].text = str(timeElapsed)
                    self.v["totalTime"].text = str(round(self.totalElapsedTimeBySumming))
    if __name__ == "__main__":
        a = clockster()

    posted in Pythonista read more
  • Tizzy

    @Vertec im a little green join the club! :D

    posted in Pythonista read more
  • Tizzy

    As a side note I would gladly pay for a Pythonista objc-util tutorial for dummies.

    posted in Pythonista read more
  • Tizzy

    @omz @Phuket2 @ccc would any of you happen to know how to set a custom brightness for the flashlight as some apps in the App Store can do? Passing anything other than an integer to setTorchMode() throws an error...

    I tried as to do device.setTorchModeOnWithLevel_() as per some objective c, and trying to recognize patterns between the. Objc c code on stack overflow and your Python example..., but get error no method found for selector..

    Tbh, I have no idea what I'm doing with objc_util .... :(

    posted in Pythonista read more
  • Tizzy

    @omz feature suggestion - text resizing in the documentation viewer - especially useful in conjunction with the newish console/docs sidebar-pinning.

    Bonus points: keyboard commands to resize (command +, command - ???)

    posted in Pythonista read more
  • Tizzy

    @MichaelC basically after you install stash, force quit Pythonista, then to launch stash you run the newly installed "launch Stash" script, then from the Stash prompt you can do pip

    posted in Pythonista read more
  • Tizzy

    @Webmaster4o is correct, as long as you're using Pythonista 2, not the Pythonista 3 beta (which you can find info about on this forum)

    posted in Pythonista read more
  • Tizzy

    Hi Moe, do you mean you're trying to stream keyboard input to a file?

    Could you provide an example of what you're doing?

    posted in Pythonista read more
Internal error.

Oops! Looks like something went wrong!