Further work

oop-refactor
Thor 4 years ago
parent 0cf50d7d56
commit e8d339f615
  1. 19
      dependencies.md
  2. 1
      dependencies.txt
  3. 1
      src/test.py
  4. 16
      src/zasd/__init__.py
  5. 41
      src/zasd/repl.py

@ -0,0 +1,19 @@
# Dependencies for third-party packages
## apscheduler
```
setuptools >= 0.7
six >= 1.4.0
pytz
tzlocal >= 1.2
```
## ptpython
```
appdirs
jedi>=0.9.0
prompt_toolkit>=3.0.0,<3.1.0
pygments
```

@ -1,7 +1,6 @@
import os
import sys
import pprint
import dateutil
#from zasd.filesystems.zfs import ZFSFilesystem
#from zasd.apsched import AsyncIOPriorityScheduler

@ -22,13 +22,6 @@ from zasd.filesystem import FilesystemRegistry
from zasd.log import configure_logging, log
from zasd.repl import repl
event_loop = asyncio.get_event_loop()
asyncio.ensure_future(repl())
scheduler = AsyncIOPriorityScheduler(
event_loop = event_loop,
executors = {'default': AsyncIOPriorityExecutor()})
async def main():
#event_loop.add_signal_handler(
# signal.SIGINT, partial(signal_handler, 'SIGINT'))
@ -47,14 +40,19 @@ async def main():
#if isatty():
# event_loop.create_task(spinner)
event_loop = asyncio.get_event_loop()
scheduler = AsyncIOPriorityScheduler(
event_loop = event_loop,
executors = {'default': AsyncIOPriorityExecutor()})
asyncio.ensure_future(repl())
asyncio.ensure_future(main())
try:
event_loop.run_forever()
finally:
log.info('Terminating')
print(file=stderr)
event_loop.close()
def signal_handler(signame):
log.info('Received %s', signame)

@ -1,13 +1,37 @@
''' Interactive Python interpreter '''
from typing import MutableMapping, Any
from typing import MutableMapping, Any, Callable, ContextManager, Dict, Optional
import builtins
import asyncio
import ptpython.repl
import re
from ptpython.repl import PythonRepl
from prompt_toolkit.patch_stdout import patch_stdout as patch_stdout_context
import zasd.config as config
@asyncio.coroutine
async def repl():
_globals = dict(
config = DictObject(config.reference(), 'config'))
_locals = dict(a = 'b')
# Create REPL.
_repl = PythonRepl(
get_globals=lambda: _globals,
get_locals=lambda: _locals,
vi_mode=True)
_repl.confirm_exit = False
_repl.highlight_matching_parenthesis = True
_repl.insert_blank_line_after_output = False
try:
with patch_stdout_context():
await _repl.run_async()
except EOFError:
quit()
class DictObject:
def __init__(self, dictionary: MutableMapping[str, Any], name):
DictObject._dictionary = dictionary
@ -47,16 +71,3 @@ class DictObject:
obj[key], name, level + 1, path = path + [key])
strs.append(value)
return '\n'.join(strs)
@asyncio.coroutine
def repl():
_globals = dict(
config = DictObject(config.reference(), 'config')
)
_locals = dict()
try:
yield from ptpython.repl.embed(
globals=_globals, locals=_locals, return_asyncio_coroutine=True,
patch_stdout=True, vi_mode=True)
except EOFError:
asyncio.get_event_loop().stop()
Loading…
Cancel
Save