[chirp_devel] [PATCH 0 of 2] [RFC] Network Source Base
Count subcategories for progress bar, to make the progress more fine-grained and linear (there's one http request per subcategory). When more subcategories are discovered, bar moves backwards.
Tom KD7LXL
# HG changeset patch # User Dan Smith dsmith@danplanet.com # Date 1334271107 25200 # Node ID cc8eaaea59612fa079c97fc63d0b81c94fc4f5c9 # Parent ece8571a5ff1c15859a897c0cd6c94b683c6ee7d [RFC] Declare a network source radio type and make editorset run do_fetch() before starting the import. This gives us time to show status for sources that need it and give it to us (such as RadioReference). Bug #00
diff -r ece8571a5ff1 -r cc8eaaea5961 chirp/chirp_common.py --- a/chirp/chirp_common.py Thu Apr 12 21:25:41 2012 -0600 +++ b/chirp/chirp_common.py Thu Apr 12 15:51:47 2012 -0700 @@ -1010,6 +1010,10 @@ class LiveRadio(Radio): pass
+class NetworkSourceRadio(Radio): + def do_fetch(self): + pass + class IcomDstarSupport: MYCALL_LIMIT = (1, 1) URCALL_LIMIT = (1, 1) diff -r ece8571a5ff1 -r cc8eaaea5961 chirpui/editorset.py --- a/chirpui/editorset.py Thu Apr 12 21:25:41 2012 -0600 +++ b/chirpui/editorset.py Thu Apr 12 15:51:47 2012 -0700 @@ -251,6 +251,25 @@ def do_import(self, filen): try: src_radio = directory.get_radio_by_image(filen) + except Exception, e: + common.show_error(e) + return + + if isinstance(src_radio, chirp_common.NetworkSourceRadio): + ww = importdialog.WaitWindow("Querying...", self.parent_window) + ww.show() + def status(status): + ww.set(float(status.cur) / float(status.max)) + try: + src_radio.status_fn = status + src_radio.do_fetch() + except Exception, e: + common.show_error(e) + ww.hide() + return + ww.hide() + + try: if src_radio.get_features().has_sub_devices: src_radio = self.choose_sub_device(src_radio) except Exception, e:
# HG changeset patch # User Dan Smith dsmith@danplanet.com # Date 1334271166 25200 # Node ID 1d6687778bf52a6b633044f2d5a8ab87283a0322 # Parent cc8eaaea59612fa079c97fc63d0b81c94fc4f5c9 [RFC] Make RadioReference push status during the fetch
Since we're walking a bunch of data, this helps the user not wonder if things are actually happening behind the scenes.
Tom, this should give you something to start with and hopefully improve a little. Bug #00
diff -r cc8eaaea5961 -r 1d6687778bf5 chirp/radioreference.py --- a/chirp/radioreference.py Thu Apr 12 15:51:47 2012 -0700 +++ b/chirp/radioreference.py Thu Apr 12 15:52:46 2012 -0700 @@ -30,7 +30,7 @@ "P25" : "P25", }
-class RadioReferenceRadio(chirp_common.Radio): +class RadioReferenceRadio(chirp_common.NetworkSourceRadio): VENDOR = "Radio Reference LLC" MODEL = "RadioReference.com"
@@ -61,20 +61,34 @@
zipcode = self._client.service.getZipcodeInfo(self._zip, self._auth) county = self._client.service.getCountyInfo(zipcode.ctid, self._auth) + + status = chirp_common.Status() + status.max = 0 + for cat in county.cats: + status.max += len(cat.subcats) + status.max += len(county.agencyList) + for cat in county.cats: print "Fetching category:", cat.cName for subcat in cat.subcats: print "\t", subcat.scName result = self._client.service.getSubcatFreqs(subcat.scid, self._auth) self._freqs += result + status.cur += 1 + self.status_fn(status) + status.max -= len(county.agencyList) for agency in county.agencyList: agency = self._client.service.getAgencyInfo(agency.aid, self._auth) for cat in agency.cats: + status.max += len(cat.subcats) + for cat in agency.cats: print "Fetching category:", cat.cName for subcat in cat.subcats: print "\t", subcat.scName result = self._client.service.getSubcatFreqs(subcat.scid, self._auth) self._freqs += result + status.cur += 1 + self.status_fn(status)
def get_features(self): if not self._freqs: @@ -153,4 +167,4 @@ print rrr.get_memory(0)
if __name__ == "__main__": - main() \ No newline at end of file + main()
participants (1)
-
Tom Hayward