KermMartian wrote:
elfprince13 wrote:
What about transferring applications and Y/R/other graphing variables? It would be handy to be able to copy settings and modes from other calculators as well.
I'm pretty set on not dealing with Applications, because I really don't feel like handling all the Flash-writing shenanigans. I was assuming that transferring programs wouldn't really require graph variables or reals, so I was hoping I could just ignore them. Even GDBs are borderline, imho.


I guess in fairness if you are doing GDBs you probably don't need the individual vars.
souvik1997 wrote:
Would it be possible to transfer entire DCS folders?
Oh dear, I hadn't even thought of that. The idea of recursive transfers makes me very sad, but I suppose I could indeed make that a possibility. I'd have to add the ability to send folders, but I guess I need the ability to create remote folders with a specified parent anyway. Hell, I also need to be able to delete remote items, don't I?
Now that I uploaded version 1.1 of calcpkg, I can post "FolderTrees.py", the script I wrote earlier.

Even though it would probably be called from another Python script or module as a module, rather than a script, I made it executable for debugging purposes. It should print out some categories and files.

Here are the notes I had at the top of the file as comments:
#Todo here- exclude /os/, or do we want users to be able to see /os/ and just not send .8xus?
#Should it be rewritten to use subprocess rather than os.system? Probably, but I didn't feel like it.


Code:
#!/usr/bin/env python

import os

class Category:
   """Category object, can contain subcategories and files"""
   def __init__(self, path):
      self.path = path
      self.name = path[path.rfind('/') + 1:]

      self.categories = []
      self.files = []

   def __str__(self):
      return self.path

   def __repr__(self):
      return self.path

   def __cmp__(self, other):
      if self.path < other.path:
         return -1
      elif self.path > other.path:
         return 1
      else:
         return 0

class File:
   """File object, contained by categories"""
   def __init__(self, fileName, category):
      self.fileName = fileName
      self.category = category

   def __str__(self):
      return self.fileName

   def __repr__(self):
      return self.fileName

def produceTreeStructure():
   """Return an array containing the top-level Categories in the /83plus/ directory"""
   #First, get all files in 83+ folder in order to find categories
   os.system("calcpkg list -f -c 83plus '' > calcpkg.out")
   listOutput = open("calcpkg.out", "rt")
   categories = []
   for line in listOutput:
      if not "83plus" in line:
         continue
      categoryPath = line[:line.find(" ")]
      category = Category(categoryPath)
      if not category in categories:
         categories.append(category)
   listOutput.close()
   
   #Now, for all categories, run a list, create Files for files that are in them, Categories for categories that aren't
   for category in categories:
      os.system("calcpkg list -f -c " + category.path[:-1] + " '' > calcpkg.out")
      listOutput = open("calcpkg.out", "rt")
      for line in listOutput:
         if not "83plus" in line:
            continue
         categoryPath = line[:line.find(" ")]
         if categoryPath == category.path:
            fileName = line[line.find(" "):].strip(" ")[:-1]
            newFile = File(fileName, category)
            category.files.append(newFile)
         elif category.path in categoryPath:
            for searchCategory in categories:
               if searchCategory.path == categoryPath:
                  category.categories.append(searchCategory)
                  categories.remove(searchCategory)
                  break
      listOutput.close()
   os.remove("calcpkg.out")

   #Now, clean up the root "categories" array... this is a rather exhaustive process
   newCategories = []
   for category in categories:
      if ("os" in category.path or "bbcbasic" in category.path):
         newCategories.append(category)
         continue
      rootStr = category.path[:category.path.rindex("/")]
      try:
         rootStr = rootStr[:rootStr.rindex("/") + 1]
      except:
         continue
      root = Category(rootStr)
      if root in newCategories or rootStr == "83plus":
         continue
      for loopCategory in categories:
         if rootStr in loopCategory.path:
            root.categories.append(loopCategory)
      newCategories.append(root)

   #And one last pass to clean up the really annoying sub directories
   categories = []
   for category in newCategories:
      valid = False
      for loopCategory in newCategories:
         if category.path in loopCategory.path and category != loopCategory:
            valid = True
            category.categories.append(loopCategory)
            for subCategories in loopCategory.categories:
               try:
                  category.categories.remove(subCategories)
               except:
                  pass
      if ("bbcbasic" in category.path or "os" in category.path):
         valid = True
      if valid:
         categories.append(category)

   #Debugging code to verify the script is working
   print categories
   print categories[1].categories
   print categories[2].files

   return categories

if __name__ == '__main__':
   produceTreeStructure()
To keep you all appraised of Sandpaper progress, for the past three days I've been toying with generating, requesting, and sending file lists. Local population of file listing works, remote listing works, and sending/requesting listings is limping towards completion. Once I get it to send and receive a pre-generated list, I'll make it display said list and let the user scroll through, then I'll go back to the file-listing routine and make it work properly for all file types and subfolders.
*bump* Fixed all aspects of transferring file lists between calculators, as far as I can tell. Next up is displaying local and remote file lists, making them clickable, and making them scrollable.
TC01 wrote:
Now that I uploaded version 1.1 of calcpkg, I can post "FolderTrees.py", the script I wrote earlier.

Even though it would probably be called from another Python script or module as a module, rather than a script, I made it executable for debugging purposes. It should print out some categories and files.

Here are the notes I had at the top of the file as comments:
#Todo here- exclude /os/, or do we want users to be able to see /os/ and just not send .8xus?
#Should it be rewritten to use subprocess rather than os.system? Probably, but I didn't feel like it.


It would not be very difficult to send an 8xu, I don't see why they wouldn't be able to.
Via Doors CS and CALCnet, you mean?
Yes, that is what I mean. Because you are overwriting the OS anyway, you can take quite a few liberties in the receiving process that you wouldn't be able to when receiving other files.
SirCmpwn wrote:
Yes, that is what I mean. Because you are overwriting the OS anyway, you can take quite a few liberties in the receiving process that you wouldn't be able to when receiving other files.
True, but you'd still have to unlock flash and everything, and if I'm not going to bother for sending Apps, I don't think I'll do it for an OS, either.
Fair enough. I actually thing OS receiving would be pretty straightforward, much simpler than app receiving.
SirCmpwn wrote:
Fair enough. I actually thing OS receiving would be pretty straightforward, much simpler than app receiving.
Probably, but at this point I'm thinking that those two are more than I'm anticipating this particular project covering. Not that over-the-air DCS updates wouldn't be epic winning.
KermMartian wrote:
Not that over-the-air DCS updates wouldn't be epic winning.


Replacing the application that you have to return to after exiting might require the highest degree of epic winnery yet.
Precisely, which is why I'm so hesitant to try anything akin to that sort of mischief. Smile First things first, at any rate; I'm planning how I'm going to turn the program list into a rendered on-screen list that's properly scrollable.
*bump* After a few days of hard work threaded into my real-life work, I give you.... file lists! The remote file list is actually being transferred over CALCnet, even though it's identical to the local list. The routine I wrote and debugged is pushing icons, names, and hotspots into the DCS GUI. Next I need to write the hotspot handlers and a more complete file listing routine (and push those folder icons down one pixel).

woot. Nice work Kerm =D
elfprince13 wrote:
woot. Nice work Kerm =D
Many thanks, Elfprince, it creeps along slowly but surely. Smile As mentioned in the zContest topic, I'm considering submitting this to that contest, which would give me a December deadline.
*bump* Finally got a chance this weekend to work on Sandpaper again! I designed and wrote the code to search the SymTable (not the VAT), find strings, GDBs, pictures, and matrices, then construct lists that can be sent around of those programs, plus the code to display said folder contents on-screen. Check out the results in this uni-calculator screenshot:



Since I'm trying to get a minimum working example of sending items by the end of zContest, next up is moving between folders in the remote pane, which should be much easier with all the code I wrote for the features in the above screenshot, then I can move on to listing program folders. After that will be displaying the folder name in that blank space for the same, and after that will be the file send/receive popup followed by the send/receive code.
Well, what I can see before it flashes and goes away looks good. Can't wait to see being able to browse the files listed. Awesome job, so far.

Edit:

Oh hey, fixed screenshot! Now that looks pretty awesome Very Happy
Oh, that reminds me that I don't actually have scrolling properly working as far as hotspots to click, even though I have the backend code to handle scrolling up and down and not going further than the two ends of the file lists. Very Happy
very nice Kerm! Looks excellent, I really like the look of it so far. I can't wait until you get far enough for a demo Very Happy
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» Goto page Previous  1, 2, 3, 4, 5, 6  Next
» View previous topic :: View next topic  
Page 3 of 6
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement