{ "info": { "author": "", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "~~~~~~~\r\ntxSpore\r\n~~~~~~~\r\n\r\n.. contents::\r\n :depth: 1\r\n\r\n\r\n=======\r\nHistory\r\n=======\r\n\r\nThe Twisted Spore API was created more for fun than anything else. There's\r\nreally nothing special about it; all resource fetching is done with a Twisted\r\nweb client (twisted.web.client.getPage).\r\n\r\nWhen possible (given the async nature of the Twisted Spore API), code from the\r\nblocking Python API was reused. This was done in an effort to maintain\r\nfunctional compatibility with the synchronous Spore Python API. However, as it\r\nturned out, there were several features missing from the other API as well as\r\nsome REST resources that don't work anymore as originally written in that API.\r\n\r\n\r\n============\r\nDependencies\r\n============\r\n\r\nTo use this API as-is, you will need to have Twisted (Python) installed.\r\nDownlowds for the latest release are always linked on the main page:\r\n\r\nhttp://twistedmatrix.com/\r\n\r\n\r\n===================\r\nFurther Development\r\n===================\r\n\r\nIf there is interest in having a synchronous Python API updated to the latest\r\nfunctionality as released by spore.com, I would be more than willing to add\r\nexplicit support for a non-Twisted API in this source code such that that it\r\ncould be used even when Twisted is not installed.\r\n\r\nFor more details on coming changes, be sure to read the TODO section.\r\n\r\n\r\n============\r\nInstallation\r\n============\r\n\r\nDevelopment\r\n-----------\r\n\r\nIf you want to develop for txSpore or use the latest code we're working on, you\r\ncan install from the sources. You'll need bzr installed, and then just do the\r\nfollowing::\r\n\r\n $ bzr branch lp:txspore\r\n $ cd txspore\r\n $ sudo python setup.py install\r\n\r\n\r\nEasy Install\r\n------------\r\n\r\nYou can use the setuptools easy_install script to get txSpore on your system::\r\n\r\n $ sudo easy_install txSpore\r\n\r\n\r\nManual Download\r\n---------------\r\n\r\nYou can manually download the source tarball from the Python Package Index by\r\nvisiting the following URL:\r\n\r\n http://pypi.python.org/pypi/txSpore/\r\n\r\nYou'll need to untar and gunzip the source, cd into the source directory, and\r\nthen you can do the usual::\r\n\r\n $ sudo python setup.py install\r\n\r\n\r\nChecking the Source\r\n-------------------\r\n\r\nOnce installed, as long as you have Twisted installed on your system and the\r\ntrial script in your PATH, you can test the source code by executing this\r\nanywhere::\r\n\r\n $ trial txspore\r\n\r\nThat will run the test suite and report on the success and failure of any unit\r\ntests.\r\n\r\n\r\n=====\r\nUsage\r\n=====\r\n\r\nInteractive Prompt\r\n------------------\r\n\r\nSometimes it's not very practical to run Twisted code from the Python\r\ninterpreter (timeouts can be a problem and accessing results from callbacks can\r\nbe awkward). Regardless, there is one below showing the use of both the REST\r\nservice API as well as the static data service provided at spore.com.\r\n\r\nThe achivement data for a user that's available via the REST service only has\r\nIDs associated with it, no text data. The Spore data service does have the\r\ntext. We're going to need to get both. First, though, let's do some initial\r\nimports and setup some callbacks::\r\n\r\n >>> from cStringIO import StringIO\r\n >>> from twisted.internet import reactor\r\n >>> from twisted.internet.defer import DeferredList\r\n >>> from txspore.client import AsyncClient\r\n >>>\r\n >>> results = []\r\n >>> data = StringIO()\r\n >>>\r\n >>> def setResults(callback_results, results):\r\n ... results.append(callback_results)\r\n ...\r\n >>> def printError(error):\r\n ... print error.getErrorMessage()\r\n ...\r\n >>> def finish(ignored):\r\n ... reactor.stop()\r\n ...\r\n\r\nWith our callbacks and errback defined, as well as some global objects for\r\nholding result data, we're ready to make the client calls::\r\n\r\n >>> client = AsyncClient()\r\n >>> d1 = client.rest.getAchievementsForUser(\"oubiwann\", 0, 20)\r\n >>> d1.addCallback(setResults, results)\r\n >> d1.addErrback(printError)\r\n >>\r\n >>> d2 = client.data.getAchievementDataXML(fd=data)\r\n >>> d2.addErrback(printError)\r\n >>\r\n >>> d = DeferredList([d1, d2])\r\n >>> d.addCallback(finish)\r\n >> reactor.run()\r\n\r\nLet's make sure we get the number of achievements we expected and then take a\r\nquick peek at some of the achiements associated with this user::\r\n\r\n >>> achievements = results.pop()\r\n >>> len(achievements)\r\n 20\r\n >>> for achievement in sorted(achievements)[0:4]:\r\n ... print achievement.guid\r\n ...\r\n 0xaec66642!0x0770b845\r\n 0x0cc8b2c9!0xb9ff8f07\r\n 0x0cc8b2c9!0x19988ceb\r\n 0x0cc8b2c9!0xe1f5cf25\r\n\r\nWe now have the IDs, but not the text. Let's get the latter::\r\n\r\n >>> from txspore import util\r\n >>> from txspore import model\r\n >>>\r\n >>> xmlTree = util.XML(data.getvalue())\r\n >>> achievementsModel = model.RecursiveDataModel(xmlTree)\r\n >>> len(achievementsModel.achievements)\r\n 124\r\n >>> achievementsLookup = {}\r\n >>> for achievement in achievementsModel.achievements:\r\n ... achievementsLookup[achievement.id] = (\r\n ... achievement.name, achievement.description)\r\n ...\r\n\r\nWith the lookup dictionary populated, we can re-print our user results with\r\nfriendlier output::\r\n\r\n >>> for achievement in sorted(achievements):\r\n ... try:\r\n ... print \"%s: %s\" % achievementsLookup[achievement.guid]\r\n ... except KeyError:\r\n ... print \"Couldn't find key '%s' ...\" % achievement.guid\r\n ...\r\n Couldn't find key '0xaec66642!0x0770b845' ...\r\n Wanderer Passion: Play as a Wanderer\r\n Quest Master: Complete 150 missions in the Space stage\r\n Gunner: Destroy at least 500 other space vessels\r\n Relentless: Complete the Civilization stage 10 times\r\n Tribal: Complete the Tribal stage 10 times\r\n Maxis Scout: Earn 100 badges in the Space stage\r\n Shaman Hero: Achieve Master Badge Level 10 as a Shaman\r\n Universe In A Box: Play in every stage and every creator\r\n Slugger: Finish Creature stage without legs\r\n Bestial: Play the Creature stage 10 times\r\n Max Power: Build a creature with maximum stats in at least 4 abilities...\r\n Spore Fan: Spend 50 hours in your Spore galaxy\r\n Biologist: Make and publish 100 creatures\r\n Bard Passion: Play as a Bard\r\n General Custer: Lead 30 posse members to their death\r\n Spice Hoarder: Control every resource node on the planet simultaneously\r\n Rolling Thunder: Complete the Civilization stage in less than an hour\r\n Missionary: Finish the Civilization stage with more than 8 religious cities\r\n Speed Demon: Finish Creature stage within an hour\r\n\r\n\r\nDemo\r\n----\r\n\r\nIn the top-level source directory for txSpore, there is an examples directory.\r\nThis contains a demo web application that shows:\r\n\r\n* one simple way of integrating txSpore into a web app\r\n\r\n* how to use the client to get user data and assets\r\n\r\n* how to use callbacks to process results\r\n\r\n\r\nUnit Tests\r\n----------\r\n\r\nThe unit tests are actually one of the best places to look for details about\r\nusage. There're two test modules that could provide very enlightening when\r\nfiguring out how to use the txSpore API:\r\n\r\n* txspore/tests/test_client.py - basic client usage, and how to handle results\r\n\r\n* txspore/tests/test_model.py - detailed view of available attributes on\r\n returned model objects.\r\n\r\n\r\n===================\r\nAPI Quick Reference\r\n===================\r\n\r\nBelow are listed the objects and the methods that are available on the txSpore\r\nclient class.\r\n\r\n\r\ntxspore.client.AsyncClient.rest\r\n-------------------------------\r\n\r\n * __init__\r\n\r\n * parameter: parent\r\n\r\n * getAchievementsForUser\r\n\r\n * parameters: username, start, length\r\n\r\n * getAssetsForSporeCast\r\n\r\n * parameters: sporeCastID, start, length\r\n\r\n * getAssetsForUser\r\n\r\n * parameters: username, start, length\r\n\r\n * getBuddiesForUser\r\n\r\n * parameters: username, start, length\r\n\r\n * getCommentsForAsset\r\n\r\n * parameters: assetID, start, length\r\n\r\n * getDailyStats (takes no parameters)\r\n\r\n * getInfoForAsset\r\n\r\n * parameter: assetID\r\n\r\n * getProfileInfo\r\n\r\n * parameter: username\r\n\r\n * getSporeCastsForUser\r\n\r\n * parameter: username\r\n\r\n * getStatsForCreature\r\n\r\n * parameter: creatureID\r\n\r\n * searchAssets\r\n\r\n * parameters: searchType, start, length, assetType\r\n\r\n\r\ntxspore.client.AsyncClient.data\r\n-------------------------------\r\n\r\n * __init__\r\n\r\n * parameter: parent\r\n\r\n * getAchievementDataXML\r\n\r\n * parameters: path, fd\r\n\r\n * getAchievementIcon\r\n\r\n * parameters: achievementID, path, fd\r\n\r\n * getAchievementText\r\n\r\n * parameters: path, fd\r\n\r\n * getAssetDataLargePNG\r\n\r\n * parameters: assetID, path, fd\r\n\r\n * getAssetDataSmallPNG\r\n\r\n * parameters: assetID, path, fd\r\n\r\n * getAssetDataXML\r\n\r\n * parameters: assetID, path, fd\r\n\r\n * getLargeCard\r\n\r\n * parameters: assetID, path, fd\r\n\r\n * getPaintIcon\r\n\r\n * parameters: remoteFilename, path, fd\r\n\r\n * getPaintInfo\r\n\r\n * parameters: path, fd\r\n\r\n * getPartIcon\r\n\r\n * parameters: remoteFilename, path, fd\r\n\r\n * getPartInfo\r\n\r\n * parameters: blockType, path, fd\r\n\r\n\r\ntxspore.client.AsyncClient.atom\r\n-------------------------------\r\n\r\n * __init__\r\n\r\n * parameter: parent\r\n\r\n * getAssetsForUser\r\n\r\n * parameter: username\r\n\r\n * getEventsForAsset\r\n\r\n * parameter: assetID\r\n\r\n * getEventsForUser\r\n\r\n * parameter: username\r\n\r\n * getSporeCastFeed\r\n\r\n * parameter: sporeCastID\r\n\r\n * searchAssets\r\n\r\n * parameters: searchType, start, length\r\n\r\n\r\ntxspore.client.AsyncClient.cache\r\n--------------------------------\r\n\r\n * __init__ (takes no parameters)\r\n\r\n * get\r\n\r\n * parameter: key\r\n\r\n * purge (takes no parameters)\r\n\r\n * remove\r\n\r\n * parameter: key\r\n\r\n * set\r\n\r\n * parameters: key, object\r\n\r\n\r\n==========\r\nKnown Bugs\r\n==========\r\n\r\n* None so far\r\n\r\n====\r\nTODO\r\n====\r\n\r\n* Update all methods with epydoc-parsable docstrings.\r\n\r\n* Create an aspect for non-spore API methods... something like CustomAspect.\r\n\r\n* Add support for using a complete, up-to-date sync API without the need to\r\n have Twisted installed.\r\n\r\n* Fix the threading/logging stuff in test_saveFileWithError.\r\n\r\n* Add search functions to client.\r\n\r\n* Add code for everything below line 244 in txspore.original.SporeAPICoreUtils.\r\n\r\n* Add mode code to the demo and/or add more demos/examples.\r\n\r\n* Encode results as utf-8\r\n\r\n\r\nAsyncClient.custom\r\n------------------\r\n\r\n* Get useful achievement data with secondary query in\r\n client.getAchievementsForUser.\r\n\r\n* Most popular creation by archetype/category with name and .png (suggested by\r\n MrAlex92; more details: http://forum.spore.com/jforum/posts/list/27693.page).\r\n\r\n* Order/filter creations by limb count, complexity, specific traits, size\r\n (suggested by Technodude12).\r\n\r\n* Order/filter by flying/swimming patterns (suggested by docpippo).\r\n\r\n* Add methods for the following user data (suggested by Eochaid1701):\r\n\r\n - creation count\r\n\r\n - latest creation (name)\r\n\r\n - latest creation (.png)\r\n\r\n - a tuple-result: username, creation count, latest creation (name), latest\r\n creation (.png)\r\n\r\n - might want to add user icon, latest achiemvement, tagline, joined date\r\n\r\n\r\n=======\r\nChanges\r\n=======\r\n\r\n0.0.1 to 0.0.2\r\n--------------\r\n\r\n* Added a new client object; calls are made with methods now, instead of\r\n module-level functions.\r\n\r\n* Added support for caching method results.\r\n\r\n* Moved the REST service API methods into their own object and instantiated\r\n it on a \".rest\" attribute of the client class.\r\n\r\n* Moved the static data service API methods into their own object and\r\n instantiated it on a \".data\" attribute of the client class.\r\n\r\n* Added support for Spore Atom (\"RSS\") data, available on the \".atom\" attribute\r\n of the client object.\r\n\r\n* Implemented the last remaining Spore API method that hadn't been added.\r\n\r\nVersion 0.0.1\r\n-------------\r\n\r\n* Initial release of txSpore, supporting most of the REST and static data APIs.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "txSpore", "package_url": "https://pypi.org/project/txSpore/", "platform": "", "project_url": "https://pypi.org/project/txSpore/", "project_urls": null, "release_url": "https://pypi.org/project/txSpore/0.0.2/", "requires_dist": null, "requires_python": null, "summary": "An asynchronous Spore Python API using Twisted.", "version": "0.0.2" }, "last_serial": 801107, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "33a6ccff0c8a60b06c6767afcc8c6afa", "sha256": "1849c949da16d846285b60b4fc3ff4e8a92ef431d769d7448d109d18a1d2a813" }, "downloads": -1, "filename": "txSpore-0.0.1.tar.gz", "has_sig": false, "md5_digest": "33a6ccff0c8a60b06c6767afcc8c6afa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 100313, "upload_time": "2009-09-14T06:42:13", "url": "https://files.pythonhosted.org/packages/45/43/5247b7dd1a34799ad2b4079ce11682b559f83c60f6e47cf3c937bc689a2e/txSpore-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "9198760b719775910d5828be459f5dd0", "sha256": "2a7d37fc2fa55bffe654c02c7622c700b00904f7c18bbefac4e04c008fdc7b54" }, "downloads": -1, "filename": "txSpore-0.0.2.tar.gz", "has_sig": false, "md5_digest": "9198760b719775910d5828be459f5dd0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 133830, "upload_time": "2009-09-17T06:52:38", "url": "https://files.pythonhosted.org/packages/76/b1/cf13d8e1db82e5d238c9c0e851bd0fab3afd823ffbd6827025f0b6c97fd3/txSpore-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9198760b719775910d5828be459f5dd0", "sha256": "2a7d37fc2fa55bffe654c02c7622c700b00904f7c18bbefac4e04c008fdc7b54" }, "downloads": -1, "filename": "txSpore-0.0.2.tar.gz", "has_sig": false, "md5_digest": "9198760b719775910d5828be459f5dd0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 133830, "upload_time": "2009-09-17T06:52:38", "url": "https://files.pythonhosted.org/packages/76/b1/cf13d8e1db82e5d238c9c0e851bd0fab3afd823ffbd6827025f0b6c97fd3/txSpore-0.0.2.tar.gz" } ] }