rmtew / livecoding Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/livecoding
License: Other
Automatically exported from code.google.com/p/livecoding
License: Other
= livecoding = == Version == 2.01 == Licensing and copyright == Files declaring other licenses and authors are derivative, and remain under the specified licenses and copyright by the original authors. All other files are licensed under the BSD license, which is included as the file 'LICENSE'. == Authors == * Richard Tew <[email protected]> == Overview == This library implements something which is often called live coding or code reloading. It allows an application to have any Python code which might be part of it updated as the files the code is in are changed - while the application is running. * No need to restart the application in order to incorporate changes made to Python scripts. * No need to execute Python scripts manually each time you want to use the code within them. The way the library goes about this is by having directories containing Python scripts registered to be monitored so that any time a change is made to a script the code within it can be reloaded and put in place transparently. Note that these directories should not be those of standard Python modules available for normal import. The reason for this is that this library manually processes the contents of registered directories and places them so that they can be imported. By handling this itself, this allows the library to know enough to apply changes to modules as they happen. == Library Directories == * examples: Example code to illustrate use of this library. * filechanges: A library that manages the process of monitoring script files and notifying registrants about modifications to them. * scripts: A script directory for use by the unit tests. * scripts2: Additional scripts for use by the unit tests. * tests: Unit tests for this library. == Design Decisions == There are several noteworthy design decisions which were made during the implementation of this library: 1. Use of a custom import scheme. 1. Ignoring removals, whether removal of files or removal of functions or classes from files.
The namespace leak tracking system stores a dictionary on the code
reloader, that uses as a key the attribute name and as the value, a tuple
of script path and script version. There is no way of knowing in what
namespace the attribute by that name was leaked.
The leaks should be tracked on a per namespace basis. Either
namespace.__name__ can be used as a key, or some clean way can be found of
storing it on/in the namespace. In fact, that might be the best solution.
Original issue reported on code.google.com by [email protected]
on 13 Feb 2010 at 7:43
What steps will reproduce the problem?
Changing a class definition results in an error
class test(object):pass
to
class test:pass
or
class test(dict):pass
Original issue reported on code.google.com by [email protected]
on 21 Jul 2008 at 11:58
If you have a class variable, and then you delete it, the following error
appears:
File "livecoding.py", line 368, in ProcessChangedFile
del oldObject[k]
TypeError: 'type' object does not support item deletion
Original issue reported on code.google.com by [email protected]
on 21 Jul 2008 at 11:58
Are unit tests copied over in MODE_UPDATE? If so, they should not be.
Original issue reported on code.google.com by [email protected]
on 23 Feb 2010 at 3:24
These aspects of the override functionality need to be completed:
* Ability to specify how the given function is overridden.
* Replace the original version.
* Wrap the original version.
* Chained before the original version.
* Chained after the original version.
* Complete the functionality to inject an override.
* Complete the functionality to remove an override.
Other aspects:
* Solid error handling.
* Should be possible to place overrides and wrap them for
error handling. Perhaps with the option to restore the
original version if an override errors, or to remove
just that override whether it restores the original version
or leaves a sequence of others.
* If the error handling is there to ensure the override works
it might be removal after the first call. Although perhaps
it is better that it remains permanently.
* Duration.
* An override might be present for N calls.
* An override might be present for a period of time.
Original issue reported on code.google.com by [email protected]
on 28 Dec 2006 at 4:27
on python 2.5.4, livecoding 0.2, on mac os x leopard:
$ python test_reloading.py
WARNING:root:TODO, implement leakage compatibility case
............E.E
======================================================================
ERROR: testUpdateSameFileReload_ClassFunctionUpdate
(__main__.CodeReloadingObstacleTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_reloading.py", line 451, in
testUpdateSameFileReload_ClassFunctionUpdate
self.failUnless(ret.defaults == (True,), "Function argument default
value not updated")
AttributeError: 'tuple' object has no attribute 'defaults'
======================================================================
ERROR: testUpdateSameFileReload_FunctionUpdate
(__main__.CodeReloadingObstacleTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_reloading.py", line 551, in
testUpdateSameFileReload_FunctionUpdate
newScriptFile = self.ReloadScriptFile(scriptDirectory, scriptDirPath,
"functions.py", mangleCallback=cb)
File "test_reloading.py", line 100, in ReloadScriptFile
result = self.codeReloader.ReloadScript(oldScriptFile)
File "/Library/Python/2.5/site-packages/livecoding/reloader.py", line
126, in ReloadScript
newScriptFile = self.CreateNewScript(oldScriptFile)
File "/Library/Python/2.5/site-packages/livecoding/reloader.py", line
142, in CreateNewScript
newScriptFile = scriptDirectory.LoadScript(filePath, namespacePath)
File "/Library/Python/2.5/site-packages/livecoding/namespace.py", line
316, in LoadScript
return self.scriptFileClass(filePath, namespacePath)
File "/Library/Python/2.5/site-packages/livecoding/namespace.py", line
29, in __init__
self.Load(filePath)
File "/Library/Python/2.5/site-packages/livecoding/namespace.py", line
38, in Load
self.codeObject = compile(script, self.filePath, "exec")
File "/Users/sa/Code/src/livecoding/scripts/functions.py", line 2
^
SyntaxError: invalid syntax
----------------------------------------------------------------------
Ran 15 tests in 0.379s
on python 2.6.2, livecoding 0.2, on mac os x leopard:
$ python2.6 test_reloading.py
WARNING:root:TODO, implement leakage compatibility case
..F...........E
======================================================================
ERROR: testUpdateSameFileReload_FunctionUpdate
(__main__.CodeReloadingObstacleTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_reloading.py", line 551, in
testUpdateSameFileReload_FunctionUpdate
newScriptFile = self.ReloadScriptFile(scriptDirectory, scriptDirPath,
"functions.py", mangleCallback=cb)
File "test_reloading.py", line 100, in ReloadScriptFile
result = self.codeReloader.ReloadScript(oldScriptFile)
File "/Users/sa/Code/src/livecoding/reloader.py", line 126, in ReloadScript
newScriptFile = self.CreateNewScript(oldScriptFile)
File "/Users/sa/Code/src/livecoding/reloader.py", line 142, in
CreateNewScript
newScriptFile = scriptDirectory.LoadScript(filePath, namespacePath)
File "/Users/sa/Code/src/livecoding/namespace.py", line 316, in LoadScript
return self.scriptFileClass(filePath, namespacePath)
File "/Users/sa/Code/src/livecoding/namespace.py", line 29, in __init__
self.Load(filePath)
File "/Users/sa/Code/src/livecoding/namespace.py", line 38, in Load
self.codeObject = compile(script, self.filePath, "exec")
File "/Users/sa/Code/src/livecoding/scripts/functions.py", line 2
^
SyntaxError: invalid syntax
======================================================================
FAIL: testFileChangeDetection (__main__.CodeReloaderSupportTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_reloading.py", line 788, in testFileChangeDetection
self.failUnless(game.FileChangeFunction.__doc__ == " new version ",
"Updated function doc string value still the original one")
AssertionError: Updated function doc string value still the original one
----------------------------------------------------------------------
Ran 15 tests in 0.416s
FAILED (failures=1, errors=1)
Original issue reported on code.google.com by [email protected]
on 20 Apr 2009 at 8:46
There is no setup.py, so things fail.
'/home/stuaxo/.virtualenvs/tmp/build/livecoding/setup.py'
Might also need to reorged a little.
Original issue reported on code.google.com by [email protected]
on 14 Nov 2013 at 11:35
MODE_UPDATE works by executing a changed script file into a custom globals
dictionary, then processing what is in there, transferring the interesting
bits over to the first loaded version of that script.
However, in my usage of it, I am seeing the classes in the changed script
file hanging around. So if I look up all the subclasses of a given base
class, I will find any version of those subclasses which has ever existed.
This appears to be because of the circular reference between a class and
the func_globals variable on the functions defined on it. But this does
not seem like it should be a problem.
For now, I clear the globals dictionary for a script (which is what
func_globals on every class function within that script points to) when
that script is garbage collected. Which works as a workaround.
Original issue reported on code.google.com by [email protected]
on 21 Jan 2010 at 1:59
Exceptions when import dependencies cannot be resolved are logged line by
line. Exceptions when unit tests fail are logged within one log line.
The former is noisy and unreadable. The latter is clear and readable. All
exception logging should be done in the way the latter uses.
Original issue reported on code.google.com by [email protected]
on 8 Jan 2010 at 8:59
The script directory dependency resolution has N number of attempts to
execute the scripts it has to load. This works fine, but there is
potential to make it optimal.
This could be by having it consider what it has left, and to only do as
many further attempts as are necessary to determine that everything can be
loaded or that everything cannot be loaded.
Original issue reported on code.google.com by [email protected]
on 13 Feb 2010 at 12:35
Decorated function updating has not been tested
Original issue reported on code.google.com by [email protected]
on 9 Jan 2010 at 6:00
On python 2.5.4, livecoding 0.2, on mac os x leopard,
With the simple example:
$ python run.py
Traceback (most recent call last):
File "run.py", line 31, in <module>
Run()
File "run.py", line 11, in Run
cr.AddDirectory("base", "scripts")
File "/Library/Python/2.5/site-packages/livecoding/reloader.py", line 51,
in AddDirectory
if handler.Load():
File "/Library/Python/2.5/site-packages/livecoding/namespace.py", line
175, in Load
self.LoadDirectory(self.baseDirPath)
File "/Library/Python/2.5/site-packages/livecoding/namespace.py", line
207, in LoadDirectory
namespace = self.GetNamespacePath(dirPath)
File "/Library/Python/2.5/site-packages/livecoding/namespace.py", line
168, in GetNamespacePath
relativeDirPath = os.path.relpath(dirPath, self.baseDirPath)
AttributeError: 'module' object has no attribute 'relpath'
Original issue reported on code.google.com by [email protected]
on 20 Apr 2009 at 8:42
Looking at UpdateModuleAttributes, it is clear that this function has a few
issues.
* Why is 'overwritableAttributes' passed in?
* Why are the leaked attributes collected in 'leakedAttributes' unused?
And finally, with collection of leaked and contributed attributes, who
removes leaked attributes that have been replaced?
Original issue reported on code.google.com by [email protected]
on 13 Feb 2010 at 12:45
What steps will reproduce the problem?
$ python test_reloading.py
WARNING:root:TODO, implement leakage compatibility case
..............F
======================================================================
FAIL: testUpdateSameFileReload_FunctionUpdate
(__main__.CodeReloadingObstacleTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_reloading.py", line 554, in
testUpdateSameFileReload_FunctionUpdate
self.failUnless(testFunction is not game.TestFunction, "Function not
updated by reload")
AssertionError: Function not updated by reload
----------------------------------------------------------------------
Ran 15 tests in 0.836s
FAILED (failures=1)
Original issue reported on code.google.com by [email protected]
on 26 Apr 2009 at 5:39
I switched to MOVE_UPDATE because it didn't seem to. George Oliver is
using MODE_UPDATE, and has resorted to doing 'instance.__class__ =
namespace.class'.
Original issue reported on code.google.com by [email protected]
on 9 Jan 2010 at 3:53
The code seems to follow the C# naming conventions of using camel case with
leading caps for methods and leading lowercase for instance variables. The
PEP 8 style guide for Python recommends using the
lowercase_with_underscores style for both methods and instance variables.
Following this will keep the code consistent with the prevailing style for
Python naming.
See http://www.python.org/dev/peps/pep-0008/
Original issue reported on code.google.com by [email protected]
on 10 Apr 2007 at 6:49
I thought this project was licensed under the GPL, but as pointed out on
Reddit it is not. I need to consider changing from BSD to GPL.
Original issue reported on code.google.com by [email protected]
on 21 Jan 2010 at 8:27
MODE_UPDATE does not update the base classes of a changed class. This
definitely needs to be fixed. If it is not possible to change the base
class of an object, like from object to type, then this should be a logged
warning or error with an understandable description of the reason for it.
Original issue reported on code.google.com by [email protected]
on 23 Feb 2010 at 1:27
Should have a clearer distinction between automatic and user driven updates.
Which gives the following two categories:
- Automatic updating (have to be using threads).
- User driven updates.
The user can also choose how updates are detected.
- Inline when polling.
- Accrued in a thread. These would be acquired from a queue.
This is still quite confused. But it would all be hidden away in
filechanges.
Original issue reported on code.google.com by [email protected]
on 28 Dec 2006 at 3:37
What steps will reproduce the problem?
1. Run the MUD framework.
2. Edit a slots based class that has instances.
3. Save the file.
What is the expected output? What do you see instead?
The expected output is that all instances are updated and continue to work.
Instead..
Traceback (most recent call last):
File "D:\SVN\_googlecode\sorrows-mudlib\trunk\contrib\uthread.py", line 95, in newFunction
oldFunction(*args, **kwargs)
File "D:\SVN\_googlecode\sorrows-mudlib\trunk\games\roguelike\services\world.py", line 340, in RunNPC
matches = self.FindMovementDirections(body.position)
File "D:\SVN\_googlecode\sorrows-mudlib\trunk\games\roguelike\services\world.py", line 315, in FindMovementDirections
if self.IsTileUnoccupied(tile):
File "D:\SVN\_googlecode\sorrows-mudlib\trunk\games\roguelike\services\world.py", line 285, in IsTileUnoccupied
return tile.isPassable
File "D:\SVN\_googlecode\sorrows-mudlib\trunk\games\roguelike\services\world.py", line 43, in isPassable
return self.flags & FLAG_PASSABLE
TypeError: descriptor 'flags' for 'Tile' objects doesn't apply to 'Tile' object
Please use labels and text to provide additional information.
Original issue reported on code.google.com by [email protected]
on 6 Sep 2010 at 10:30
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.