• @cvp this is very good. One more thing for now: I want to make the user's location the purple pin instead of the green/red so that it stands out. I have the location as 'Current Location' for the pin. Any ideas? Thanks

  • I guess you need to spend more time on knowing the programming language that u need to use. BTW, HTML NOT A programming lang it defined as markup language

  • @cvp school's been rough lately lol. Teacher is asking I make more modifications to the map we were talking about so that I can collect some data... I have a simple ui.load_view() I plan to make later which will ask the user if they want to mark their current location on the map. However I would need a button to be pressed for the user to get the view to work. Also, the user would need to be able to do so as many times as they like, so that multiple marks can appear on the map. The positions of the markers would need to be saved so that the next time the map is activated, the markers will reappear. I understand this is likely a fair amount of code, but any help would be greatly appreciated. I will not be able to test the code for a few hours because my iPad is at home and I am at school. If you could suggest any ideas for me to test later I would be very thankful.

  • Issue reported.

  • @ccc i depends on how you wanted to go about it. the teacher mention that some students used csv module. its a really basic class. i used what was explained in class.

  • Thank you for your help. vidmate download instasave

  • Thank You @ccc .

    You're always there :)
    And I'm sure, you can reduce this code by half !

  • @Kevin254 I didn't know the pickle module, like a lot of Python features.
    But if you want to try my solution without file, for small amount of data, try this example with several runs

    import keychain import ast my_data_str = keychain.get_password('myscript', 'pickle') print(my_data_str) if my_data_str: my_data = ast.literal_eval(my_data_str) else: my_data = {'var1':1, 'var2':2} #....process my_data['var1'] += 1 my_data['var2'] += 2 my_data_str = str(my_data) keychain.set_password('myscript', 'pickle', my_data_str)
  • @SandraGarrett more info on the .in_dll() method here

  • And the best solution (if it works):

    You could even define a shortcut with an automation "when my iDevice connects to any wifi network" with actions:

    get wifi name copy it into a file (in Shortcuts folder)

    This shortcut will run in background.

    Your script, when it needs this wifi name, should only read this file (in external Shortcuts folder ) and should get the current wifi name.

    To be tested, obviously

    Édit: automation works, at each network update, not tested with a file but with clipboard

  • @resserone13 This was helpful. Was having difficulty with creating delays and this cleared it up. Thanks for the pointer. Cheers.

  • @BurntRice you did inverse x and y

    if touch.location in self.UpCrtl.bbox: new_y = self.Player.position.y + 5 if new_y >= 0 and new_y <= 1024: self.Player.position = (self.Player.position.x, new_y) if touch.location in self.DownCrtl.bbox: new_y = self.Player.position.y - 5 if new_y >= 0 and new_y <= 1024: self.Player.position = (self.Player.position.x, new_y)
  • As usual, Python has nice batteries included...

  • This is a bad implementation method.
    There is no operation or sound, but it will be implemented in the future.


  • @RocketBlaster05 If you still require the youtube_dl module, you can do it as suggested here or alternatively a small edit I did from his script years ago (in order to get it to work, also, let me know if this code should be removed from this post). Every other week or so, you can backup then download to keep it updated

    # coding: utf-8 # author: Shaun Hevey # youtube-dl downloader is used to download youtube_dl and patch it to work in Pythonista. # Replace function came from http://stackoverflow.com/questions/39086/search-and-replace-a-line-in-a-file-in-python # Download file was adapted from Python file downloader (https://gist.github.com/89edf288a15fde45682a) import console import os import requests import shutil import tempfile import time import ui import zipfile youtubedl_dir = 'youtube_dl' youtubedl_location = './site-packages/' backup_location = './backup/youtube_dl/' youtubedl_downloadurl = 'https://yt-dl.org/downloads/latest/youtube-dl' youtubedl_unarchive_location = './temp/' files_to_change = [('utils.py','import ctypes','#import ctypes'), ('utils.py','import pipes','#import pipes'), ('YoutubeDL.py','self._err_file.isatty() and ',''), ('downloader/common.py','(\'\\r\\x1b[K\' if sys.stderr.isatty() else \'\\r\')','\'\\r\''), ('extractor/common.py',' and sys.stderr.isatty()','')] def backup_youtubedl(sender): console.show_activity('Checking for youtube-dl') if os.path.isdir(youtubedl_location+youtubedl_dir): console.show_activity('Backing up youtube-dl') if not os.path.exists(backup_location): os.makedirs(backup_location) shutil.move(youtubedl_location+youtubedl_dir,backup_location+youtubedl_dir+ time.strftime('%Y%m%d%H%M%S')) console.hide_activity() @ui.in_background def restore_youtubedl_backup(sender): if not os.path.isdir(backup_location) or not os.listdir(backup_location): console.alert('Nothing to do', 'No backups found to restore') else: folders = os.listdir(backup_location) folder = folders[len(folders)-1] shutil.move(backup_location+folder,youtubedl_location+youtubedl_dir) console.alert('Success','Successfully restored '+folder) def downloadfile(url): localFilename = url.split('/')[-1] or 'download' with open(localFilename, 'wb') as f: r = requests.get(url, stream=True) total_length = r.headers.get('content-length') if total_length: dl = 0 total_length = float(total_length) for chunk in r.iter_content(1024): dl += len(chunk) f.write(chunk) #.setprogress(dl/total_length*100.0) else: f.write(r.content) return localFilename def process_file(path): os.mkdir(youtubedl_unarchive_location) if zipfile.is_zipfile(path): zipfile.ZipFile(path).extractall(path=youtubedl_unarchive_location) @ui.in_background def update_youtubedl(sender): if os.path.exists(youtubedl_location+youtubedl_dir): msg = 'Are you sure you want to update youtubedl exists in site-packages and will be overwritten' if not console.alert('Continue',msg,'OK'): return console.show_activity('Downloading') file = downloadfile(youtubedl_downloadurl) console.show_activity('Extracting') process_file(file) console.show_activity('Moving') if os.path.exists(youtubedl_location+youtubedl_dir): shutil.rmtree(youtubedl_location+youtubedl_dir) shutil.move(youtubedl_unarchive_location+youtubedl_dir, youtubedl_location) console.show_activity('Cleaning Up Download Files') shutil.rmtree(youtubedl_unarchive_location) os.remove(file) console.show_activity('Making youtube-dl friendly') process_youtubedl_for_pythonista() console.hide_activity() def process_youtubedl_for_pythonista(): for patch in files_to_change: filename, old_str, new_str = patch replace_in_file(youtubedl_location+youtubedl_dir+'/'+filename, old_str, new_str) def replace_in_file(file_path, old_str, new_str): with open(file_path, encoding='utf-8') as old_file: #Create temp file fh, abs_path = tempfile.mkstemp() os.close(fh) # close low level and reopen high level with open(abs_path,'w', encoding='utf-8') as new_file: for line in old_file: new_file.write(line.replace(old_str, new_str)) #Remove original file os.remove(file_path) #Move new file shutil.move(abs_path, file_path) def make_button(title, action): button = ui.Button(title=title) button.action = action button.background_color ='lightgrey' button.border_color = 'black' button.border_width = 1 button.flex = 'WB' return button view = ui.View(frame=(0,0,172,132)) view.background_color = 'white' backup_button = make_button(title='Backup YoutubeDL', action=backup_youtubedl) backup_button.center = (view.width * 0.5, view.y+backup_button.height) view.add_subview(backup_button) restore_button = make_button(title='Restore YoutubeDL', action=restore_youtubedl_backup) restore_button.center = (view.width * 0.5, backup_button.y+restore_button.height*1.75) view.add_subview(restore_button) download_button = make_button(title='Download YoutubeDL', action=update_youtubedl) download_button.center = (view.width * 0.5, restore_button.y+download_button.height*1.75) view.add_subview(download_button) view.present('sheet')
  • This seems about right. Instead of swapping out via same property, I just handle the item (one at a time) using a queue

    import objc_util import time class NotificationObserver: def __init__(self, name): self.name = objc_util.ns(name) self.center = objc_util.ObjCClass("NSNotificationCenter").defaultCenter() self._observer = None self._blk = None self.queue = objc_util.ObjCClass('NSOperationQueue').new() self.queue.setName_(objc_util.ns('test')) self.ni_objs = [] '''the objc block signature. do not modify''' def _block(self, _cmd, notification): try: ni_obj = objc_util.ObjCInstance(notification).object() self.ni_objs.append(ni_obj) except Exception as ex: print(ex) '''start observing''' def start(self): #print(time.asctime() + ' starting') if self._observer: raise Exception('observer already started') self._blk = objc_util.ObjCBlock(self._block, restype=None, argtypes=[objc_util.c_void_p, objc_util.c_void_p]) self._observer = self.center.addObserverForName_object_queue_usingBlock_(self.name, None, self.queue, self._blk) objc_util.retain_global(self) def stop(self): #print(time.asctime() + ' stopping') if self._observer: self.center.removeObserver_(self._observer) self._observer = None objc_util.release_global(self)

    Trying to make the seek call as quick as possible, also cleared the list (really should be removing the item that won’t exist in case you have other player objects) before the next item plays in case another (prior) notification(s) slips through

    def looper(player): while v.on_screen: if not paused and not wait: #if hasattr(player, "item_load_time") and player.player.rate() == 0.0 and should_do_loop(): pi = player.item if pi and pi in NotificationObserver.itemDidPlay.ni_objs: NotificationObserver.itemDidPlay.ni_objs.remove(pi) player.seek(secs=0) player.player.play() player.playCount += 1 if player.layer: #console.hud_alert("vp.playCount = {}".format(player.playCount), duration=0.5) pass elif not inf: #Audio player has looped -> next item change_i_by_val(1) update_i_change() #console.hud_alert("ap.playCount = {}".format(player.playCount), duration=0.5) pass time.sleep(refresh_rate) else: time.sleep(refresh_rate_helper)
  • @JonB said:

    Have you found the json for the appex scripts?

    Yes, it is the file I have described above but it was containing old wrench's. now, when I add new appex scripts, the file is updated with these new ones.

  • @halloleooo yes, sorry, my first (deleted and purged) answer was using format but only valid with pil

  • Run:

    pip install asgiref

    Then restart. That shud do it

    But then there's this error

    Note that only Django core commands are listed as settings are not properly configured (error: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.).

    Need help with is. I believe you need to set an environment variable to point to a named Django settings-config file. Much of a gray area for me still a newbie to the stash terminal. Any heads up ?

  • I've tried to get up an running with NLTK through installer script from pypi modules and it throws the following errors on attempted install under python 2.7.

    ProtocolError: <ProtocolError for pypi.python.org/pypi: 403 [[[!!! BREAKING CHANGE !!!]]] Support for clients that do not support Server Name Indication is temporarily disabled and will be permanently deprecated soon. See https://status.python.org/incidents/hzmjhqsdjqgb and https://github.com/pypa/pypi-support/issues/978 [[[!!! END BREAKING CHANGE !!!]]]>

    I tried using pip install from stash but it failed while installing the regex module as it contains C code that required compiling.

    Any work around would be greatly appreciated.

Internal error.

Oops! Looks like something went wrong!