-
-
Notifications
You must be signed in to change notification settings - Fork 24
Home
ugit is an OTA micropython module for keeping ESPs, or other wifi enable Micropython boards, in sync with a github repository. It was designed to be used with the open muscle forearm band to supply updates for the wearable device. Please visit https://openmuscle.org to learn more.
#boot.py
import ugit
ugit.backup() # good idea to backup your files!
ugit.pull_all()
Simply put: copy ugit.py onto the micropython board.
- Copy ugit.py onto your micropython board
- modify ugit_config with the user,repository,ssid, and password
- run the ugit.pull_all()
You can use ugit without any other code in boot. It will connect to wifi and download filetree from github and copy the raw data to your board.
# boot.py
import ugit
ugit.pull_all()
If you want to use your own method of connecting to wifi you can add the isconnected=true parameter to ugit.pull_all()
#boot.py
import ugit
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect('SSID','Password')
ugit.pull_all(isconnected=True)
import ugit
wlan = ugit.wificonnect('SSID','PASSWORD')
# backup internal files
ugit.backup() # saves to ugit.backup file
# Pull single file
ugit.pull('file_name.ext','Raw_github_url')
# Pull all files
ugit.pull_all()
We plan to include a roll-back feature in the future where you can roll back to a previous state.
import ugit
ugit.build_internal_tree() #grabs internal file structure
ugit.pull(local_file_path,raw_file_url) #pulls single raw files
ugit.pull_git_tree() #pulls the github file tree from the repository
ugit.parse_git_tree() #parses the github tree file to stdout
ugit.is_directory() #checks if file path is a directory (folder).
ugit.wificonnect(ssid=ssid,password=password) #connects to wifi
Github requires a urequests header otherwise it will give you a 403 error.
Github uses main instead of master for URL api conncetion to repository tree. See source code in ugit.py for more informaiton.
NOTE if you are pulling from a non-python repository you made need to change call_trees_url to /master? instead of /main?
giturl = 'https://github.com/{user}/{repository}'
call_trees_url = f'https://api.github.com/repos/{user}/{repository}/git/trees/main?recursive=1'
raw = f'https://raw.githubusercontent.com/{user}/{repository}/master/'
See the open issues for a list of proposed features (and known issues).
As we test and update the code to work in a variety of scenarious we wish to have the following features implemented as soon as possible.
- Rollback function
- SHA1 internal hash storage - Currently ugit pulls all files
- ugit.py update function - updates the ugit.py code from this repository (currently in dev branch)
- Simplified Logging