This repository has been archived by the owner on Nov 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
80 changed files
with
1,715 additions
and
963 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,7 +85,7 @@ endpoints.txt | |
.prompt.py.history | ||
|
||
preferences.json | ||
prompt.log | ||
prompt.log* | ||
test.log | ||
|
||
.pylint | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,41 @@ | ||
Basic Usage | ||
----------- | ||
|
||
Start neo-python as follows: | ||
There are two main ways to use neo-python: ``prompt.py`` and running just the node with custom | ||
code. | ||
|
||
prompt.py | ||
""""""""" | ||
|
||
Start prompt.py on TestNet: | ||
|
||
:: | ||
|
||
python neo/prompt.py | ||
$ python prompt.py | ||
|
||
Show help with all available arguments: | ||
|
||
:: | ||
|
||
$ python prompt.py -h | ||
usage: prompt.py [-h] [-m] [-p] [-c CONFIG] [-t {dark,light}] [--version] | ||
|
||
optional arguments: | ||
-h, --help show this help message and exit | ||
-m, --mainnet Use MainNet instead of the default TestNet | ||
-p, --privnet Use PrivNet instead of the default TestNet | ||
-c CONFIG, --config CONFIG | ||
Use a specific config file | ||
-t {dark,light}, --set-default-theme {dark,light} | ||
Set the default theme to be loaded from the config | ||
file. Default: 'dark' | ||
--version show program's version number and exit | ||
|
||
|
||
|
||
Node with custom code | ||
""""""""""""""""""""" | ||
|
||
Take a look at the examples in the ``/examples`` directory: https://github.com/CityOfZion/neo-python/tree/development/examples | ||
|
||
See also the sections about "Settings and Logging" and "Interacting with Smart Contracts". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
Settings and Logging | ||
==================== | ||
|
||
neo-python has a settings module which you can use to configure several things: | ||
|
||
* The network: MainNet, TestNet, private networks or custom configs | ||
* Logging: | ||
* Smart contract event logging | ||
* Logfile (optionally rotating) | ||
* Loglevel | ||
|
||
To change settings, you have to import the settings instance like this: | ||
|
||
:: | ||
|
||
from neo.Settings import settings | ||
|
||
|
||
Setting the network | ||
""""""""""""""""""" | ||
|
||
You can use the following settings methods to configure the network: | ||
|
||
:: | ||
|
||
settings.setup_mainnet() | ||
settings.setup_testnet() | ||
settings.setup_privnet() | ||
settings.setup(config_file) | ||
|
||
By default, ``neo-python`` uses the TestNet. | ||
|
||
|
||
Logging | ||
""""""" | ||
|
||
neo-python uses the following defaults: | ||
|
||
* all events from all smart contracts are logged with loglevel INFO | ||
* loglevel is set to INFO | ||
* logging to a logfile is deactivated (prompt.py logs to prompt.log) | ||
|
||
|
||
Smart Contract Events | ||
--------------------- | ||
|
||
If you want to disable logging of all smart contract events, you can do so: | ||
|
||
:: | ||
|
||
settings.set_log_smart_contract_events(False) | ||
|
||
|
||
Changing the loglevel | ||
--------------------- | ||
|
||
To change the loglevel (eg. to also show DEBUG logs, or to only show ERRORS): | ||
|
||
:: | ||
|
||
import logging | ||
|
||
# Show everything, including debug logs: | ||
settings.set_loglevel(logging.DEBUG) | ||
|
||
# Only show errors: | ||
settings.set_loglevel(logging.ERROR) | ||
|
||
|
||
Configuring a logfile | ||
--------------------- | ||
|
||
To enable logging to a logfile: | ||
|
||
:: | ||
|
||
# Just a single logfile, with no limits or rotation: | ||
settings.set_logfile(your_logfile_path) | ||
|
||
# To enable rotation with a maximum of 10MB per file and 3 rotations: | ||
settings.set_logfile(your_logfile_path, 1e7, 3) | ||
|
||
|
||
Logging in custom code | ||
---------------------- | ||
|
||
neo-python is using `logzero <https://logzero.readthedocs.io>`_ for logging. To use a | ||
logger with the existing neo logging configuration, you can just import the logger from logzero: | ||
|
||
:: | ||
|
||
from logzero import logger | ||
|
||
# These log messages are sent to the console | ||
logger.debug("hello") | ||
logger.info("info") | ||
logger.warn("warn") | ||
logger.error("error") | ||
|
||
# This is how you'd log an exception | ||
try: | ||
raise Exception("this is a demo exception") | ||
except Exception as e: | ||
logger.exception(e) |
Oops, something went wrong.