Comments (11)
weird - what do you see in ls ~/.ipython/extensions
?
from ipython_extensions.
[~] ls ~/.ipython/extensions
21:51:07
autosave.py
On Fri, Dec 14, 2012 at 10:00 PM, Min RK [email protected] wrote:
ls ~/.ipython/extensions
http://reganmian.net/blog -- Random Stuff that Matters
from ipython_extensions.
hm, I can't imagine why that wouldn't work, then.
What do you get for:
get_ipython().extension_manager.ipython_extension_dir
And what IPython version?
from ipython_extensions.
In [77]:
get_ipython().extension_manager.ipython_extension_dir
Out[77]:
u'/Users/Stian/.ipython/extensions'
Version 0.13.1, using EPD (but have upgraded iPython using enpkg).
On Fri, Dec 14, 2012 at 10:14 PM, Min RK [email protected] wrote:
get_ipython().extension_manager.ipython_extension_dir
http://reganmian.net/blog -- Random Stuff that Matters
from ipython_extensions.
One more thing - what are the contents of that autosave.py in your
extensions folder?
from ipython_extensions.
"""Extension for managing periodic autosave of IPython notebooks
Usage:
%load_ext autosave
autosave every 30 seconds:
%autosave 30
disable autosave:
%autosave 0
invoke save from Python:
%savenb
"""
from IPython.core.magic import magics_class, line_magic, Magics
from IPython.display import Javascript, display
_autosave_js_t = """
// clear previous interval, if there was one
if (IPython.autosave_extension_interval) {{
clearInterval(IPython.autosave_extension_interval);
IPython.autosave_extension_interval = null;
}}
// set new interval
if ({0}) {{
console.log("scheduling autosave every {0} ms");
IPython.notebook.save_notebook();
IPython.autosave_extension_interval = setInterval(function() {{
console.log("autosave");
IPython.notebook.save_notebook();
}}, {0});
}} else {{
console.log("canceling autosave");
}}
"""
@magics_class
class AutoSaveMagics(Magics):
interval = 60
enabled = False
@staticmethod
def autosave_js(interval):
if interval:
print("autosaving every %is" % interval)
else:
print("autosave disabled")
display(Javascript(_autosave_js_t.format(1000 * interval)))
@line_magic
def autosave(self, line):
"""Schedule notebook autosave
Usage:
%autosave [interval]
If `interval` is given, IPython will autosave the notebook every
interval
seconds.
If interval
is 0, autosave is disabled.
If no interval is specified, autosave is toggled.
"""
line = line.strip()
if not line:
# empty line, toggle
self.enabled = bool(1 - self.enabled)
else:
interval = int(line)
if interval:
self.enabled = True
self.interval = interval
else:
self.enabled = False
self.autosave_js(self.enabled * self.interval)
@line_magic
def savenb(self, line):
"""save the current notebook
This magic invokes the same javascript as the 'Save' button in the
notebook UI.
"""
display(Javascript("IPython.notebook.save_notebook();"))
_loaded = False
def load_ipython_extension(ip):
"""Load the extension in IPython."""
global _loaded
if not _loaded:
ip.register_magics(AutoSaveMagics)
_loaded = True
print ("Usage: %autosave [seconds]")
On Fri, Dec 14, 2012 at 10:51 PM, Min RK [email protected] wrote:
One more thing - what are the contents of that autosave.py in your
extensions folder?—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-11393726.
http://reganmian.net/blog -- Random Stuff that Matters
from ipython_extensions.
Okay, then everything seems to be working perfectly. What if you define your own extension, just put an empty foo.py
in your extension folder, and try %load_ext foo
. If that doesn't work, something is wrong with your IPython installation, and you should bring that up as an IPython issue.
from ipython_extensions.
That went fine.
In [15]:
%load_ext foo
In [ ]:
On Fri, Dec 14, 2012 at 11:47 PM, Min RK [email protected] wrote:
%load_ext foo
http://reganmian.net/blog -- Random Stuff that Matters
from ipython_extensions.
Well, now that doesn't make even the slightest bit of sense. %load_ext autosave
doesn't work, even after %load_ext foo
does?
from ipython_extensions.
Of course, now it works perfectly. Apart from playing with different
notebooks, I am quite sure I have not touched the IPython setup. I'm sorry
if I have wasted your time, but glad that it works.
from ipython_extensions.
okay - I wonder why it didn't work. Might be something funky if you run %install_ext and %load_ext in the same session.
from ipython_extensions.
Related Issues (20)
- TOC doesnt load? HOT 26
- Gist button: problem grabbing notebook JSON code HOT 3
- ToC does not update on cell execution HOT 2
- ToC magic does not work in IPython 3.0 HOT 3
- TypeError: IPython is undefined toc.js:136:8 HOT 3
- Two install instructions for ToC HOT 1
- Load timeout for modules HOT 3
- contribute the nbextensions (at least toc) to ipython-contrib/IPython-notebook-extensions HOT 6
- Jupyter notebook 4 hangs with TOC extension HOT 8
- How can I contribute to the table of content extension?
- feature request: show/hide table of contents with a shortcut HOT 1
- Typo in TOC install commands
- Duplicates entries after each save/refresh HOT 1
- floating TOC is too small
- string including "] will cause In[*] problem
- Question: Will some of the extensions, like ToC, gist work w/ custom kernels? HOT 2
- install renumber-button via URL?
- Error on install HOT 1
- making margin width configurable
- Headings for TOC no more supported HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ipython_extensions.