
IT Architect and President of CADD Technologies Inc.
-
caddtec
Hi @bernard778 ,
Actually it is possible and there is a lot of ways you can do that. You can use simple python code to download zip files from either github or Pypi for example and then extracting those files into your directories in Pythonista. Also, you can use the github API with the Jose package (that is one of the capacity that I use) to download github sources. And obviously there is Stash that you can use as there is pip with it. As for PyPi, here’s an example of code that I used in the past :import urllib.request import tarfile import shutil import console import os import shutil import requests class Installer(object): def __init__(self, name, version, module_name=None): self.name = name self.version = version self.module_name = self.name.lower() if not module_name else module_name self.tarfolder = self.name + '-' + self.version self.tarname = self.tarfolder + '.tar.gz' self.tarURL = None self.keep_source = False self.keep_tarball = False def install(self, module_name=None, keep_source=False, keep_tarball=False): self.keep_source = keep_source self.keep_tarball = keep_tarball if module_name: self.module_name = module_name try: self.prepare() self.download() self.extract() self.copy() except Exception as e: print(str(e)) finally: self.clean() def prepare(self): r = requests.get('https://pypi.python.org/pypi/{}/{}/json'.format(self.name, self.version)) jdata = r.json() self.tarURL = jdata['urls'][-1]['url'] print('URL used : {}'.format(self.tarURL)) def download(self): print('Downloading {} v{}...'.format(self.name, self.version)) if self.tarURL: with urllib.request.urlopen(self.tarURL) as response, open(self.tarname, 'wb') as ofile: shutil.copyfileobj(response, ofile) print('Download Complete') def extract(self): print('Extracting...') t = tarfile.open(self.tarname) t.extractall() print('Package extracted') def copy(self): # If source is a folder if os.path.isdir(self.tarfolder + '/' + self.module_name): if os.path.isdir(self.module_name): print('Removing old package directory...') shutil.rmtree(self.module_name) print('Installing package directory...') shutil.move(self.tarfolder + '/' + self.module_name, './' + self.module_name) else: # if source is a file file = self.module_name + '.py' if os.path.isfile(self.tarfolder + '/' + file): if os.path.isfile(file): print('Removing old package file...') os.remove(file) print('Installing package file...') shutil.move(self.tarfolder + '/' + file, './' + file) def clean(self, keep_module=True): print('Cleaning up...') if not self.keep_source: if os.path.isdir(self.tarfolder): print('Removing source directory...') shutil.rmtree(self.tarfolder) if not self.keep_tarball: if os.path.isfile(self.tarname): print('Removing source tarball...') os.remove(self.tarname) if not keep_module: if os.path.isdir(self.module_name): print('Removing module directory...') shutil.rmtree(self.module_name) elif os.path.isfile('{}.py'.format(self.module_name)): print('Removing module file...') os.remove('{}.py'.format(self.module_name)) print('Done.')
Enjoy!
D
-
caddtec
Nice little piece of code! Thanks, I will definitely use it.
D
-
caddtec
Hi @omz,
I have a weird bug... I was working on one of my projects with pyui files. I wanted to change the name of the component (a table view) and to my surprise it deleted the component. Actually, it deleted the component because of the backspace keystroke (since I wanted to change the name). Then I realized that also, any of the direction keys (up, down, left, right) weren’t working as well. All the other keys however are working. I then realized it was the physical keyboard that didn’t work in the pyui file. When I use the on-screen keyboard, everything works including the backspace. And only in the pyui fille display because if, for example, I try to use the backspace key from the physical keyboard from, let’s say the run text field (when you press a few seconds on the « play » icon), it’ll work.Let me know if you need more info.
D -
caddtec
@omz Yeah I thought so (about the fact it is difficult with physical keyboard). I’ll just have to make do, it is not so problematic so no worries ;o). However, could be a good idea to do like the emoji keyboard however: when we select the PyKeys, it shows the keyboard by default (on screen) and then when we select another keyboard, let’s say English, then the on-screen keyboard disappear and you can then continue using the physical keyboard as always. IMHO I think I would prefer to show the on-screen keyboard by default instead of having to press the button in the toolbar above the hidden keyboard.
As for the App Store validation, I abandoned a long time ago the idea of understanding! ;o)And thanks for the feedback!
-
caddtec
I was just trying the new keyboard PyKeys and notice what seems to be a problem... that whenever I enable it, I see only the small upper part of every buttons unless I show the whole keyboard (I use a physical keyboard by the way). I am on iOS 12 with the new iPad Pro 12.9.
Is it suppose to work that way? Am I the only one that it happens? -
caddtec
Soooooo great to have a new version! Thanks @omz for the beta! Just tried out most of my apps, scripts ans unit tests. Everything seems to work perfectly!
Will continue testing and report any error I find.Again thanks!
D -
caddtec
I may have answered a little fast. It seems like your label does not get initialized (since the NoneType)... I expect it is the bFac element that is not initialized but it could be that it just does not exist. Is the sender the button? If so, maybe the bFac object is not in the super view. Try printing the keys to the superview[‘view2’] to see if the bFac element is there.
-
caddtec
I there! Actually, it is pretty simple. Just access the ‘text’ attribute of the ‘title’ element.
Cheers!
D -
caddtec
Never mind, I understand my problem!
At first I thought it was because the module is in cache but I restarted Pythonista and the problème was still there. However, it gave me a hint: how about the cache. That is when I realized the I am loading that very same module within pythonista_startup, which happens before I use my current directory.
Problem solved! Probably the fastest resolution on the forum... my bad! LOL!! :o))
-
caddtec
Hello everyone,
There seems to be a problem or maybe I misunderstood the search path algorithm... I have a module in site-packages-3 and the same one but in an other dev directory (iCloud) to work on the next version. With the new WorkingCopy directory sync feature, it is just awesome to code on my iPad! However, even though when I print the sys.path and I can see that my dev directory (current directory) is really first in the array over site-packages-3, it still uses site-packages-3 and thus my old module instead of the one I want to test in my current dev directory.
I have tried to look for a similar problem in the forum and elsewhere on the web but nothing. Did anyone encountered this error? Am I not understanding the search algorithm right in Pythonista3?
Any help would be very much appreciated.
D