Xo-get: Difference between revisions
Crazy-chris (talk | contribs) m (use olpc-austria as repository) |
|||
(57 intermediate revisions by 19 users not shown) | |||
Line 1: | Line 1: | ||
<table border="0"> |
|||
XO-Get is a very simple package-installer for the olpc xo-laptop. |
|||
<tr> |
|||
* The repository syncs with this page: http://wiki.laptop.org/go/Xo-get/Repository |
|||
<td valign="top">__TOC__</td> |
|||
* Infos stored in a local sqlite3 db (in ~/.xo_get/main.db) |
|||
<td valign="top" style="padding:10px 26px;">[[Image:activity-xoget.png]]</td> |
|||
* Supported commands: |
|||
<td valign="top" style="width:300px; text-align:center;"> |
|||
xo-get.py update |
|||
'''<font color="green">XO-Get</font>''' is a very simple package-installer / manager, used for installing, testing and removing activities for / on the xo-laptop and emulators. |
|||
xo-get.py list [categories/category_name] |
|||
xo-get.py search tag/activity_name |
|||
xo-get.py install activity_name |
|||
'''xo-get.py''' |
|||
'''<font color="green">News</font>''': We are currently developing a [[Xo-get/Xo-get-gtk|Graphical User Interface]] with [[PyGTK]]</td> |
|||
#! /usr/bin/env python |
|||
</tr> |
|||
import os |
|||
</table> |
|||
import sys |
|||
import urllib2 |
|||
import sqlite3 |
|||
== About xo-get == |
|||
* [http://www.olpc-europe.org/browse/xo-get.py xo-get.py] (GPL) |
|||
class Activity: |
|||
* [http://dev.laptop.org/git?p=projects/xo-get;a=tree Source Tree] |
|||
name = u"" |
|||
* [http://xo-get.olpc.at/repository/ Activity Repositories] |
|||
desc = u"" |
|||
* [[Xo-get/Xo-get-gtk|Graphical User Interface]] |
|||
xo_url = u"" |
|||
category = u"" |
|||
== Supported commands == |
|||
tags = u"" |
|||
Run this within Sugar in Terminal activity as user |
|||
class Database: |
|||
db_path = "" |
|||
(not as root nor su nor sudo) |
|||
db_filename = "activities.db" |
|||
cur = ""; |
|||
con = ""; |
|||
./xo-get.py update |
|||
./xo-get.py list ['categories' / category_name] |
|||
def __init__(self, db_path): |
|||
./xo-get.py search keyword |
|||
self.db_path = db_path |
|||
./xo-get.py install activity_name / activity_file.xo |
|||
./xo-get.py remove activity_name / activity_file.xo / activity_directory |
|||
# Change Directory |
|||
./xo-get.py start activity_name |
|||
try: os.mkdir(self.db_path) |
|||
./xo-get.py status ['log'] |
|||
except: pass |
|||
'''Explanation:''' |
|||
os.chdir(self.db_path) |
|||
: <table border="0"><tr><td style="width:70px;">''update''</td><td>Updates the Database</td></tr><tr><td>''list''</td><td>Lists installable Activities</td></tr><tr><td>''search''</td><td>Searches for tags, names, descriptions</td></tr><tr><td>''install''</td><td>Installs the given Activity</td></tr><tr><td>''remove''</td><td>Removes an Activity</td></tr><tr><td>''start''</td><td>Starts Activity</td></tr><tr><td>''status''</td><td>List all installed Activities</td></tr></table> |
|||
# Init DB |
|||
create_db = True |
|||
== Usage == |
|||
if os.path.isfile(self.db_filename): create_db = False |
|||
=== Installation of xo-get === |
|||
wget http://xo-get.olpc.at/xo-get.py |
|||
print "- Loading db [%s/%s]:" % (self.db_path, self.db_filename), |
|||
chmod u+x xo-get.py |
|||
self.con = sqlite3.connect(self.db_filename) |
|||
self.cur = self.con.cursor() |
|||
=== Update the xo-get repository database=== |
|||
self.cur.execute("-- types unicode") |
|||
./xo-get.py update |
|||
if create_db: |
|||
=== Installation of xo-get GUI === |
|||
# Setup New Database |
|||
./xo-get.py install xo-get |
|||
self.cur.execute("CREATE TABLE 'activities' ('id' INTEGER PRIMARY KEY AUTOINCREMENT, 'name' VARCHAR( 100 ) NOT NULL, 'desc' VARCHAR( 355 ) NOT NULL, 'xo_url' VARCHAR( 255 ) NOT NULL, 'category' VARCHAR( 255 ) NOT NULL, 'tags' VARCHAR( 255 ) NOT NULL);") |
|||
: Note: Joyride 1702, although it installed ok. When i click on the frame icon to run it. Flashes for awhile, then goes away. I ran it in terminal by '''xo-get.py start xo-get''' and appears to run ok. (Filing some bugs and suggestions too. :) --[[User:Ixo|ixo]] 02:11, 17 February 2008 (EST) |
|||
self.con.commit() |
|||
print "created" |
|||
sugar-install-bundle/media/<usb stick name> |
|||
else: |
|||
print "ok" |
|||
=== Usage Examples === |
|||
'''List installed Activities''' |
|||
# q = "SELECT * FROM activities WHERE 1" |
|||
./xo-get.py status |
|||
# print self.query(q) |
|||
'''Installing & Removing''' |
|||
def query(self, q): |
|||
./xo-get.py install simcity |
|||
dataList = [] |
|||
./xo-get.py remove simcity |
|||
self.cur.execute(q) |
|||
data = self.cur.fetchall() |
|||
'''Local .xo files''' |
|||
if data: dataList = [list(row) for row in data] |
|||
./xo-get install simcity.xo |
|||
return dataList |
|||
./xo-get remove simcity.xo |
|||
def commit(self, q): |
|||
=== Name Assistant === |
|||
self.cur.execute(q) |
|||
* Search, list, install and remove activities with typing only the beginning of the activity's/category's name as parameter |
|||
self.con.commit() |
|||
List the category "Fun Games": |
|||
./xo-get.py list fun |
|||
class XOGet: |
|||
Install CC Licensing Activity: |
|||
# domain = "http://wiki.laptop.org" |
|||
./xo-get.py install cc |
|||
# path = "/go/Xo-get/Repository" |
|||
Removing simcity |
|||
./xo-get.py remove simc |
|||
domain = "http://www.olpcaustria.org" |
|||
path = "/mediawiki/index.php/Xo-get/Repository" |
|||
=== GCompris === |
|||
List GCompris activities: |
|||
localpath = "%s/%s" % (os.path.expanduser( '~' ), ".xo_get") |
|||
./xo-get.py list gcompris |
|||
Install GCompris activities: |
|||
def __init__(self): |
|||
./xo-get install gcompris-... |
|||
print |
|||
Install all GCompris activities (> 100): |
|||
print " xo-get" |
|||
./xo-get install gcompris |
|||
print " ======" |
|||
== Repositories == |
|||
if len(sys.argv) == 1: |
|||
Newer versions of xo-get (>1.0) use a [http://xo-get.olpc.at/repository/ central repository] ([http://xo-get.olpc.at/repository/xoget.xml xml]), which is synced daily with the sub-'repositories'. Advantages of this structure are |
|||
print " use: - update\n - list {categories / [category_name]} \n - search [activity_name] / [tag]\n - install [activity_name]" |
|||
* 'xo-get update' will not break on changes in the repositories |
|||
sys.exit(0) |
|||
* supplying with filesizes and system-names (which sometimes differ from the wiki-names) |
|||
* much less traffic on updates |
|||
# Loading DB |
|||
* backup repositories |
|||
self.db = Database(self.localpath) |
|||
if sys.argv[1] == "update": self.update() |
|||
Repository Listing: |
|||
if sys.argv[1] == "list": self.list() |
|||
# [[Activities]] |
|||
if sys.argv[1] == "search": self.search() |
|||
# http://gcompris.net/incoming/xo/ |
|||
if sys.argv[1] == "install": self.install() |
|||
def list(self): |
|||
It's possible to add / change repositories on request ([[Xo-get#Contributors|mail]]). Also, any ideas for further developments are welcome! |
|||
print |
|||
q = "SELECT name, desc, category, tags FROM activities WHERE 1" |
|||
print "- Listing", |
|||
== Bugs / Issues == |
|||
if len(sys.argv) > 2: |
|||
Please file a ticket for any bug you find to the 'xo-get' component here: http://dev.laptop.org/newticket |
|||
if sys.argv[2] == "categories": |
|||
print "Categories:" |
|||
q = "SELECT DISTINCT category FROM activities WHERE 1 ORDER BY category ASC" |
|||
== Feature Request / Wishlist == |
|||
res = self.db.query(q) |
|||
* [[Xo-get/Wishlist|Add an item]] |
|||
for r in res: |
|||
{{:Xo-get/Wishlist}} |
|||
print " -",r[0] |
|||
return True |
|||
else: |
|||
== Changelog == |
|||
print "Category '%s'" % sys.argv[2] |
|||
* 1.2.3: Switched to one [http://xo-get.olpc.at/repository/ central repository], lots of minor fixes |
|||
q = "%s AND category LIKE '%s'" % (q, sys.argv[2]) |
|||
else: |
|||
print "All Activities" |
|||
== Contributors == |
|||
'''Author''' |
|||
q = "%s%s" % (q, " ORDER BY category ASC, name ASC") |
|||
* [[User:Crazy-chris|Chris Hager]] (chris at linuxuser dot at) |
|||
res = self.db.query(q) |
|||
spaces = 18 |
|||
'''Testering''' |
|||
spaces2 = 8 |
|||
* [[User:Jaume|Jaume Nualart]] |
|||
for r in res: |
|||
* [[User:ixo|ixo]] - testering as much as I can. Submitted bug reports. |
|||
print " - [%s]" % r[2], " " * (spaces2 - len(r[2])), r[0], "." * (spaces - len(r[0])), r[1] |
|||
print |
|||
If you have ideas *and* some spare time: contact us! This project is open for anyone :-) |
|||
def search(self): |
|||
print |
|||
if len(sys.argv) > 2: |
|||
[[Category:Activities]] |
|||
s = sys.argv[2].replace(" ", "_") |
|||
[[Category:Developers]] |
|||
print "- Results for '%s':" % s |
|||
[[Category:Resources]] |
|||
[[Category:Package management]] |
|||
q = "SELECT name, desc, category FROM activities WHERE tags LIKE '%s%s%s' OR name LIKE '%s%s%s'" % ('%', s, '%', '%', s, '%') |
|||
[[Category:Activity installation]] |
|||
res = self.db.query(q) |
|||
<gallery> |
|||
spaces = 18 |
|||
Image:Example.jpg|Caption1 |
|||
spaces2 = 8 |
|||
Image:Example.jpg|Caption2 |
|||
for r in res: |
|||
</gallery> |
|||
print " - [%s]" % r[2], " " * (spaces2 - len(r[2])), r[0], "." * (spaces - len(r[0])), r[1] |
|||
else: |
|||
print "- Please supply query-string (eg: 'xo-get search quiz')" |
|||
print |
|||
def install(self, s = None): |
|||
print |
|||
if s == None: |
|||
if len(sys.argv) > 2: |
|||
s = sys.argv[2].replace(" ", "_") |
|||
else: |
|||
print "- Plase supply an activity_name (eg: 'xo-get install xo_imagequiz')" |
|||
print |
|||
return False |
|||
print "- Installing Activity '%s'" % s |
|||
q = "SELECT xo_url FROM activities WHERE name='%s'" % s |
|||
res = self.db.query(q) |
|||
# No xo_url means no found activity |
|||
if len(res) == 0: |
|||
print " - No matching name found." |
|||
q = "SELECT name FROM activities WHERE name LIKE '%s'" % s |
|||
res = self.db.query(q) |
|||
if len(res) == 0: |
|||
print " - Nothing found. Please try 'xo-get search'" |
|||
print |
|||
return False |
|||
else: |
|||
print " - Found quite similar name: '%s'" % res[0][0] |
|||
# Only Upper/Lowercase Problem |
|||
if s.lower() == res[0][0].lower(): |
|||
self.install(res[0][0]) |
|||
return True |
|||
# Else Ask |
|||
i = "" |
|||
while i != 'y' and i != 'n': |
|||
print " - use this? [y/n]", |
|||
i = raw_input() |
|||
if i == "y": |
|||
self.install(res[0][0]) |
|||
return True |
|||
else: |
|||
return False |
|||
i = "" |
|||
while i != 'y' and i != 'n': |
|||
print "- Do you want to proceed? [y/n]", |
|||
i = raw_input() |
|||
if i == "n": return False |
|||
# Okay, we have the xo_url |
|||
url = res[0][0] |
|||
fn = "%s/%s" % (self.localpath, res[0][0][res[0][0].rindex('/')+1:]) |
|||
# print "- %s => %s" % (url, fn) |
|||
print "- Download => %s" % (fn) |
|||
xo = urllib2.urlopen(url).read() |
|||
f = open(fn, "w") |
|||
f.write(xo) |
|||
print "- Starting Installation" |
|||
os.system("sugar-install-bundle %s" % fn) |
|||
print "- Activity installed!" |
|||
print |
|||
def update(self): |
|||
print |
|||
print "- update from %s%s" % (self.domain, self.path) |
|||
content = urllib2.urlopen("%s%s" % (self.domain, self.path)).read() |
|||
content = content[content.index('<table border="0"'):] |
|||
content = content[:content.index('</table>')] |
|||
print "- clearing database:", |
|||
self.db.commit("DELETE FROM activities WHERE 1") |
|||
print "ok" |
|||
print "- adding activities:", |
|||
content_arr = content.split("<tr>") |
|||
act_count = 0 |
|||
for act_html in content_arr: |
|||
# Extract Activities |
|||
if act_html.count("<td>") > 0: |
|||
# Add Activity |
|||
act_html = act_html.replace("</td>", "") |
|||
act_html = act_html.replace("</tr>", "") |
|||
a = Activity() |
|||
act_html_arr = act_html.split("<td>") |
|||
# Name |
|||
a.name = act_html_arr[1].strip().replace(" ", "_") |
|||
if a.name.count('">') > 0: |
|||
a.name = a.name[a.name.index('">')+2:] |
|||
a.name = a.name[:a.name.index('<')] |
|||
if a.name != "": |
|||
# XO Url |
|||
a.xo_url = act_html_arr[2].strip() |
|||
a.xo_url = a.xo_url[a.xo_url.index("http:"):] |
|||
if a.xo_url.count('"') > 0: a.xo_url = a.xo_url[:a.xo_url.index('"')] |
|||
# DESC |
|||
a.desc = act_html_arr[3].strip() |
|||
# DESC |
|||
a.category = act_html_arr[4].strip() |
|||
# DESC |
|||
a.tags = act_html_arr[5].strip() |
|||
q = "INSERT INTO activities (name, xo_url, desc, category, tags) VALUES ('%s', '%s', '%s', '%s', '%s')" % (a.name, a.xo_url, a.desc, a.category, a.tags) |
|||
act_count += 1 |
|||
# print q |
|||
self.db.commit(q) |
|||
# print |
|||
print act_count |
|||
print "- xo-get is now up-to-date" |
|||
print |
|||
if __name__ == "__main__": |
|||
xoget = XOGet() |
Latest revision as of 18:11, 20 November 2011
XO-Get is a very simple package-installer / manager, used for installing, testing and removing activities for / on the xo-laptop and emulators.
|
About xo-get
Supported commands
Run this within Sugar in Terminal activity as user
(not as root nor su nor sudo)
./xo-get.py update ./xo-get.py list ['categories' / category_name] ./xo-get.py search keyword ./xo-get.py install activity_name / activity_file.xo ./xo-get.py remove activity_name / activity_file.xo / activity_directory ./xo-get.py start activity_name ./xo-get.py status ['log']
Explanation:
update Updates the Database list Lists installable Activities search Searches for tags, names, descriptions install Installs the given Activity remove Removes an Activity start Starts Activity status List all installed Activities
Usage
Installation of xo-get
wget http://xo-get.olpc.at/xo-get.py chmod u+x xo-get.py
Update the xo-get repository database
./xo-get.py update
Installation of xo-get GUI
./xo-get.py install xo-get
- Note: Joyride 1702, although it installed ok. When i click on the frame icon to run it. Flashes for awhile, then goes away. I ran it in terminal by xo-get.py start xo-get and appears to run ok. (Filing some bugs and suggestions too. :) --ixo 02:11, 17 February 2008 (EST)
sugar-install-bundle/media/<usb stick name>
Usage Examples
List installed Activities
./xo-get.py status
Installing & Removing
./xo-get.py install simcity ./xo-get.py remove simcity
Local .xo files
./xo-get install simcity.xo ./xo-get remove simcity.xo
Name Assistant
- Search, list, install and remove activities with typing only the beginning of the activity's/category's name as parameter
List the category "Fun Games":
./xo-get.py list fun
Install CC Licensing Activity:
./xo-get.py install cc
Removing simcity
./xo-get.py remove simc
GCompris
List GCompris activities:
./xo-get.py list gcompris
Install GCompris activities:
./xo-get install gcompris-...
Install all GCompris activities (> 100):
./xo-get install gcompris
Repositories
Newer versions of xo-get (>1.0) use a central repository (xml), which is synced daily with the sub-'repositories'. Advantages of this structure are
- 'xo-get update' will not break on changes in the repositories
- supplying with filesizes and system-names (which sometimes differ from the wiki-names)
- much less traffic on updates
- backup repositories
Repository Listing:
It's possible to add / change repositories on request (mail). Also, any ideas for further developments are welcome!
Bugs / Issues
Please file a ticket for any bug you find to the 'xo-get' component here: http://dev.laptop.org/newticket
Feature Request / Wishlist
Improvements
- Position Quit-button the standard way / use the Toolbar
- Better Installation and Removal Feedback
- Auto-Refresh, Refresh with graphical representation
- Bigger Scrollbars / Autoscroll on KeyDown
- Less scrolling: Wrap Description, Changable width of columns
- Better "Information": Icon, Version Number
- Highlight Activities without checking
- Hide Apply Button after Installation (which does nothing)
- Change the "Close" button label to "Show List". "Close" currently implies closing the application given the current context of the application and the full screen dialog box.
- checkbox for showing version #.
- Legend.. what the heck does the (*) mean ???
- Group activities by, and alpha sort list (Allow collapsible groups)
- Base pre-installed, non-removable
- Installed Activities
- Groups of packaged activities, such as GCompris
- Arrow keys
- Left/Right - scroll left/right
- Up/Down - scroll up/down
- Remove all custom packages, [Button] (except of course xo-get :)
New Features
- Self-Update screen for the GUI
- Preferences
- where to save files
- clean old .xo's
- GUI: Install .xo from disk / usb
- Button for 'check for Activity updates' (compare installed versions with versions available)
- Button for 'update all'
- Add entries for installed activities in the Journal for a common deletion/removal mechanism.
Changelog
- 1.2.3: Switched to one central repository, lots of minor fixes
Contributors
Author
- Chris Hager (chris at linuxuser dot at)
Testering
- Jaume Nualart
- ixo - testering as much as I can. Submitted bug reports.
If you have ideas *and* some spare time: contact us! This project is open for anyone :-)