omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. samaklis
    3. Posts

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    • Profile
    • Following 0
    • Followers 0
    • Topics 8
    • Posts 26
    • Best 1
    • Controversial 0
    • Groups 0

    Posts made by samaklis

    • RE: Remove reference to UIWebView

      @cvp Thanks for the info! The issue was fixed based on editing the binary as per post. I hope that @omz will update the framework so we don’t have to do this going forward.

      posted in Pythonista
      samaklis
      samaklis
    • Remove reference to UIWebView

      Hi, does anyone know how to remove the UIWebView from the Py3Kit frame work and rebuild the framework in xCode? Looks like apple no longer accepts application submissions with UIWebView references, and they will not allow an application uploaded. The framework has the module already compiled in it.

      As per their message:

      ITMS-90809: Deprecated API Usage - New apps that use UIWebView are no longer accepted. Instead, use WKWebView for improved security and reliability. Learn more (https://developer.apple.com/documentation/uikit/uiwebview).

      Thanks

      posted in Pythonista
      samaklis
      samaklis
    • RE: Python3 Xcode template broken because of deprecated UIWebView

      Same issue here... I am under the impression that Pythonista may be an abandoned project...

      posted in Pythonista
      samaklis
      samaklis
    • RE: Issue with segmented control and radius fill

      Actually changing the corner_radius of the segment control somewhat does the trick.

      The below example does what I originally intended. It’s amazing what a cup of coffee and the next day does to the brain! :-)

      import ui
      v =ui.View()
      v.background_color = 'black'
      v.frame = (0,0,400,200)
      s = ui.SegmentedControl()
      s.segments = ['aaa','bbb']
      s.background_color = 'white'
      s.corner_radius = 5
      s.frame = (10,50,380,100)
      v.add_subview(s)
      v.present('sheet') ```
      posted in Pythonista
      samaklis
      samaklis
    • RE: Issue with segmented control and radius fill

      Thanks for the replies. What I was trying to achieve is to blend the background so the segmented control does not look squared. So in your example with the yellow color background those yellow cornered should be black and the segment looks rounded which is what is somehow done when you use the default white background on a view as per code below.

      I was under the impression that there was some way by altering the corner radius and that there was a post originally on the forums but unfortunately I could not find it.

      import ui
      v =ui.View()
      v.background_color = 'white'
      v.frame = (0,0,400,200)
      s = ui.SegmentedControl()
      s.segments = ['aaa','bbb']
      s.frame = (10,50,380,100)
      v.add_subview(s)
      v.present('sheet') ```
      posted in Pythonista
      samaklis
      samaklis
    • Issue with segmented control and radius fill

      I have a segmented control that when the view it is a member of has say a black background color and I sent the background color of the segment control to be white, you can see the square ends of the border which are also filled with the background (white) color, so the whole control is squared rather than “rounded”

      Is there a way to also set the space between the rounded edges then the rectangle to be the same as the background color of the view? (not sure how to put in a picture, but I hope it is easy enough to visualize)

      Thanks

      posted in Pythonista
      samaklis
      samaklis
    • RE: Detecting deselecting a row in a ui.ListDataSource

      Extending it worked perfectly. Thanks

      posted in Pythonista
      samaklis
      samaklis
    • Detecting deselecting a row in a ui.ListDataSource

      A table view has the following two delegate methods defined

      
          def tableview_did_select(self, tableview, section, row):
              # Called when a row was selected.
           
              # this is implemented in ListDataSource
              pass
      
          def tableview_did_deselect(self, tableview, section, row):
              # Called when a row was de-selected (in multiple selection mode).
      
              # this is NOT implemented in ListDataSource...
              pass
      
      

      It looks as though the ListDataSource object only implements the first one, so I am not able to determine when multiple selection is enabled in edit mode, after the user may select and deselect any rows, what rows remain selected.

      Has anyone come across this issue before?

      
      class ListDataSource(builtins.object)
       |  Methods defined here:
       |  
       |  __init__(self, items=None)
       |      Initialize self.  See help(type(self)) for accurate signature.
       |  
       |  reload(self)
       |  
       |  tableview_accessory_button_tapped(self, tv, section, row)
       |  
       |  tableview_can_delete(self, tv, section, row)
       |  
       |  tableview_can_move(self, tv, section, row)
       |  
       |  tableview_cell_for_row(self, tv, section, row)
       |  
       |  tableview_delete(self, tv, section, row)
       |  
       |  tableview_did_select(self, tv, section, row)
       |  
       |  tableview_move_row(self, tv, from_section, from_row, to_section, to_row)
       |  
       |  tableview_number_of_rows(self, tv, section)
       |  
       |  tableview_number_of_sections(self, tv)
       |  
       |  ----------------------------------------------------------------------
       |  Data descriptors defined here:
       |  
       |  __dict__
       |      dictionary for instance variables (if defined)
       |  
       |  __weakref__
       |      list of weak references to the object (if defined)
       |  
       |  items
      
      
      posted in Pythonista
      samaklis
      samaklis
    • RE: Check if iOS device is in light or dark mode

      I realized that there is already a function that works correctly when it comes to detection the light/dark mode at any screen, built into the ui module...

      In case anyone has the same problem the below does the trick:

      ui.get_ui_style() 
      
      posted in Pythonista
      samaklis
      samaklis
    • RE: Add label to scroll view in UI editor.

      This is an old thread but the functionality of how to make fields as children nodes of a scroll view is documented here: http://omz-software.com/editorial/docs/ios_workflows/special/action-custom-ui.html

      Scroll View – A scrollable canvas, to add content to it, tap it and select “Subviews…” from the context menu.

      posted in Pythonista
      samaklis
      samaklis
    • RE: Check if iOS device is in light or dark mode

      @mcriley821 I have a quick question. I have implemented the function you gave me in a “utility” module and it works fine when calling it from the “main” view. If I call it after loading another “sheet” view, from within that view’s code, the function returns without detecting the theme as it is set in iOS.

      Any ideas why the same function would work correctly from the main view and not from other views?

      Thanks

      From the main view calling the check periodically:

      class ThemeThread(threading.Thread):
          def __init__(self, event, views=()):
              threading.Thread.__init__(self)
              self.stopped = event
              self.views = views
              
      
          def run(self):
              while not self.stopped.wait(2.0):
                  mode = utility.get_device_mode()
                  print('mode for main screen: {}'.format(mode))
                  if mode == 'dark':
                      self.change_bg_color('black')
                  else:
                      self.change_bg_color('white') 
      

      From the other module after loading the “sheet” view:

      
      class AppConfiguration(object):
          
          def __init__(self):
              self.utility = Utility()
              self.config_file = 'app_configuration.json'
              self.screen = ui.load_view("screens_configuration")
              mode = self.utility.get_device_mode()
              print('mode returns: {}'.format(mode))
      
      

      My utility module code:

      
          def get_device_mode(self):
              traits=objc_util.ObjCClass('UITraitCollection').currentTraitCollection()
              mode=traits.userInterfaceStyle()
              
              print('utility mode: {}'.format(mode))
              if mode==2:
                  return 'dark'
              else:
                  return 'light'
      
      

      Console output:

      utility mode: 2
      utility mode: 2
      mode for main screen: dark
      utility mode: 2
      mode for main screen: dark
      utility mode: 1
      mode returns: light
      utility mode: 2
      mode for main screen: dark
      utility mode: 2
      mode for main screen: dark
      utility mode: 2
      mode for main screen: dark
      main view will close...
      
      posted in Pythonista
      samaklis
      samaklis
    • RE: SSL: CERTIFICATE_VERIFY_FAILED during handshake

      Thanks for the feedback.

      Not sure how exactly to interpret the below but below is what I get back as the "Issuer" information from my certificate. COMODO Certification Authority seems to be trusted based on the list in the link you provided.

      CN = COMODO RSA Domain Validation Secure Server CA
      O = COMODO CA Limited
      L = Salford
      S = Greater Manchester
      C = GB

      In regards to the openssl changes, they are quite extensive (4 years) worth, and I am not sure I can quite pick out what change may have had an adverse effect, although I did go through their CHANGES file.

      Wouldn't the fact that I can replicate the issue outside of Pythonista "prove" that this is not specific to iOS but specific to the openssl version used by it?

      posted in Pythonista
      samaklis
      samaklis
    • RE: SSL: CERTIFICATE_VERIFY_FAILED during handshake

      Unfortunately, this issue is back again. I came to realize that there must be something related to iOS 13.5 vs 13.4.* that breaks the SSL for Pythonista. It has nothing to do with a do not trust list or configuration on the server side. Every other client can connect fine.

      I noticed that the ssl.py in Pythonista is from 2016. At this point I cannot open a secure websocket connection on my iOS devices where every other client, Windows, Mac, run the below code fine. In addition browsers have no issues connecting to the server as well.

      This leaves me to believe that there must be some connection to the iOS update and the SSL version in Pythonista that breaks the ability to talk via secure websocets on iOS.

      I am on Pythonista version 3.3 (330025) default interpreter 3.6.1
      iOS 13.5.1

      I have also submitted a bug: https://github.com/omz/Pythonista-Issues/issues/652

      import ssl
      import socket
      
      
      host = 'my_host'
      
      context = ssl.create_default_context()
      
      with socket.create_connection((host, 9001)) as sock:
          with context.wrap_socket(sock, server_hostname=host) as ssock:
              print(ssock.version())
      

      I have tested the issue by installing a local version of openssl: OpenSSL 1.0.2f 28 Jan 2016 which is the same that Pythonista comes with and when I issue the command openssl s_client connect host:port I get the below (look at error in return code)

      No client certificate CA names sent
      Peer signing digest: SHA512
      Server Temp Key: ECDH, P-256, 256 bits
      ---
      SSL handshake has read 5357 bytes and written 443 bytes
      ---
      New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES256-GCM-SHA384
      Server public key is 2048 bit
      Secure Renegotiation IS supported
      Compression: NONE
      Expansion: NONE
      No ALPN negotiated
      SSL-Session:
          Protocol  : TLSv1.2
          Cipher    : ECDHE-RSA-AES256-GCM-SHA384
          Session-ID: 3B19973E06CB84FCBB96178FA11FE78A13AC697854FBBD51A895B39B65829C4E
          Session-ID-ctx:
          Master-Key: DDBE9EAFC7FC20E6956EB694FCF1621B495E24EAB134D5EB44BB4A22134138B638047F571DB113CCA3D86DC1C9196D8B
          Key-Arg   : None
          PSK identity: None
          PSK identity hint: None
          SRP username: None
          TLS session ticket lifetime hint: 7200 (seconds)
          TLS session ticket:
          0000 - 04 f6 10 db 51 72 36 ff-01 ef 3a a0 16 c8 62 02   ....Qr6...:...b.
          0010 - b1 98 95 76 50 76 e4 12-af 28 d8 4c d1 26 75 2f   ...vPv...(.L.&u/
          0020 - 7a de ed e0 0b d7 0a 9f-b1 c9 6c af f3 4a 4c 1d   z.........l..JL.
          0030 - 41 7a 23 37 73 8b 21 90-2c a6 23 f7 11 30 28 8b   Az#7s.!.,.#..0(.
          0040 - 9f fc 1f d2 f9 07 f8 e5-5d a6 00 02 9d 9f ad f1   ........].......
          0050 - e1 a6 c9 48 3a 17 25 95-98 ae 16 f5 38 e0 a0 f8   ...H:.%.....8...
          0060 - ce f1 51 59 31 57 fa 30-49 39 f1 55 b9 e7 48 b7   ..QY1W.0I9.U..H.
          0070 - ae 12 a3 fb 6c 76 52 23-d5 53 08 0b 59 01 77 b2   ....lvR#.S..Y.w.
          0080 - 31 0e 3a b5 10 b7 6b a4-b6 1f 2b b5 73 af b9 c7   1.:...k...+.s...
          0090 - 7f 56 85 15 07 33 c4 4c-d9 11 00 7b 2d b1 b3 26   .V...3.L...{-..&
      
          Start Time: 1591927357
          Timeout   : 300 (sec)
          Verify return code: 20 (unable to get local issuer certificate)
      

      When I run the same command with version: OpenSSL 1.1.1f 31 Mar 2020 I get no errors (look at return code=0):

      No client certificate CA names sent
      Peer signing digest: SHA512
      Peer signature type: RSA
      Server Temp Key: ECDH, P-256, 256 bits
      ---
      SSL handshake has read 5381 bytes and written 434 bytes
      Verification: OK
      ---
      New, TLSv1.2, Cipher is ECDHE-RSA-AES256-GCM-SHA384
      Server public key is 2048 bit
      Secure Renegotiation IS supported
      Compression: NONE
      Expansion: NONE
      No ALPN negotiated
      SSL-Session:
          Protocol  : TLSv1.2
          Cipher    : ECDHE-RSA-AES256-GCM-SHA384
          Session-ID: 2D876927EB37E715EACF58C6AEA2EDA5EC8EE3D4067D089C2CAE256345B83A8C
          Session-ID-ctx:
          Master-Key: 2AF552551C08BF01A0B8F166510E83BFDF03439A67698DA68502BC9B84891DD099C04545B73CD2D9EC729CF47D533AF5
          PSK identity: None
          PSK identity hint: None
          SRP username: None
          TLS session ticket lifetime hint: 7200 (seconds)
          TLS session ticket:
          0000 - 04 f6 10 db 51 72 36 ff-01 ef 3a a0 16 c8 62 02   ....Qr6...:...b.
          0010 - 15 49 44 26 0e 71 18 58-54 27 28 0c 8b bb ce 38   .ID&.q.XT'(....8
          0020 - 5c b2 f8 33 13 f8 3a 14-ee 23 c8 c5 40 fe 80 c0   \..3..:..#..@...
          0030 - 05 ea f5 5e 94 4b bb 33-54 ab 46 f1 0c e8 b0 b7   ...^.K.3T.F.....
          0040 - 52 e3 51 e1 20 d6 9f 58-c6 40 5f 11 58 e1 dd de   R.Q. ..X.@_.X...
          0050 - db 05 3c 69 74 38 3b 6e-3f 93 21 bb 1d 4e 48 4a   ..<it8;n?.!..NHJ
          0060 - cf 19 f1 fd ec ac 0b e3-93 b4 4e 12 d1 03 61 9a   ..........N...a.
          0070 - 24 d6 c8 13 19 ba cd 9c-5a 1d 0c da ab e3 c5 b2   $.......Z.......
          0080 - 2d 79 f2 91 31 29 08 32-c7 1b c5 ef 89 bf fb db   -y..1).2........
          0090 - e4 66 2b a8 bb e3 23 76-ac a1 83 bb 4a 5f 4b 6c   .f+...#v....J_Kl
          00a0 - 6d 36 e2 71 ac 68 23 4b-de 6f 5c d7 b1 8c d1 5c   m6.q.h#K.o\....\
      
          Start Time: 1591927401
          Timeout   : 7200 (sec)
          Verify return code: 0 (ok)
          Extended master secret: yes
      

      I think this proves that the included openssl that comes with Pythonista (which ssl.py sources) needs to be upgraded to a later version

      posted in Pythonista
      samaklis
      samaklis
    • RE: SSL: CERTIFICATE_VERIFY_FAILED during handshake

      Turns out that the service publishing to MQTT had some errors, and also Pythonista somehow was caching the handshake. After restarting both the error cleared out.

      Thanks for the reply.

      posted in Pythonista
      samaklis
      samaklis
    • SSL: CERTIFICATE_VERIFY_FAILED during handshake

      I have a very simple snippet of code which makes a connection to my server running MQTT and subscribes to a topic. This is a simplified example of a bigger application. The code was working fine until today on both my iPhone and iPad.

      All of the sudden I am getting an error in the Framework/pylib/ssl.py in do_handshake saying: SSL: CERTIFICATE_VERIFY_FAILED

      If i take the same piece of code and run it from Windows, or Mac it works fine so to me that eliminates anything being wrong with the server.

      Pythonista has not had any updates so I am at a loss as to why I am having this issue all of the sudden and especially on the Pythonista side only.

      Any help would be appreciated

      import paho.mqtt.client as mqtt
      
      # The callback for when the client receives a CONNACK response from the server.
      def on_connect(client, userdata, flags, rc):
          print("Connected with result code "+str(rc))
      
          # Subscribing in on_connect() means that if we lose the connection and
          # reconnect then subscriptions will be renewed.
          client.subscribe("weather/#")
      
      # The callback for when a PUBLISH message is received from the server.
      def on_message(client, userdata, msg):
          print(msg.topic+" "+str(msg.payload))
      
      client = mqtt.Client(transport="websockets")
      client.tls_set()
      client.on_connect = on_connect
      client.on_message = on_message
      
      client.connect("myHostName", 9001, 60)
      
      client.loop_forever()
      
      posted in Pythonista
      samaklis
      samaklis
    • RE: Check if iOS device is in light or dark mode

      @mcriley821 said:

      traits=objc_util.ObjCClass('UITraitCollection').currentTraitCollection()
      mode=traits.userInterfaceStyle()
      if mode==2:
      print(‘Dark’)
      else:
      print(‘Light’)

      Perfect, thanks

      posted in Pythonista
      samaklis
      samaklis
    • Check if iOS device is in light or dark mode

      Is there a way to check if the iPhone, iPad is in dark or light mode? The ui.get_ui_style() seems to only be querying the Pythonista app mode.

      I am looking for something that would give me access to Apple's UITraitCollection, which is inherited by the UIView but I am not sure how it can be accessed through the objc_util library if at all.

      Thanks

      posted in Pythonista
      samaklis
      samaklis
    • RE: Retrieving the iOS document directory

      @JonB True, that works too. :-) I thought Xcode had some sort of built functionality that is similar to copying bundle resources during the build.

      posted in Pythonista
      samaklis
      samaklis
    • RE: Retrieving the iOS document directory

      @JonB Is there a way to “deploy” configuration files/settings in the Documents directory when you are building the project in Xcode?

      Thanks

      posted in Pythonista
      samaklis
      samaklis
    • RE: Accessing custom labels in Contacts

      @cvp Thank you. I will try and revert back, but this looks exactly what I was looking for.

      posted in Pythonista
      samaklis
      samaklis