You are viewing a single comment's thread from:

RE: Writing an asynchronous STEEM web-app in Python with asyncsteem

in #utopian-io5 years ago (edited)

I got it all running, but just see at a blank white screen on localhost! I checked my usual 127.0.0.1:4080 It is working but not sure what my next step should be? I think it is most likely just my ssl, will check first!
2019-05-02 16:53:23 ☆ nickademous in ~/asyncsteem
± |master ✓| → python setup.py --help-commands
Standard commands:
build build everything needed to install
build_py "build" pure Python modules (copy to build directory)
build_ext build C/C++ extensions (compile/link to build directory)
build_clib build C/C++ libraries used by Python extensions
build_scripts "build" scripts (copy and fixup #! line)
clean clean up temporary files from 'build' command
install install everything from build directory
install_lib install all Python modules (extensions and pure Python)
install_headers install C/C++ header files
install_scripts install scripts (Python or otherwise)
install_data install data files
sdist create a source distribution (tarball, zip file, etc.)
register register the distribution with the Python package index
bdist create a built (binary) distribution
bdist_dumb create a "dumb" built distribution
bdist_rpm create an RPM distribution
bdist_wininst create an executable installer for MS Windows
check perform some checks on the package
upload upload binary package to PyPI

2019-05-02 16:56:10 ☆ nickademous in ~/asyncsteem
± |master ✓| → python setup.py build
running build
running build_py
creating build
creating build/lib
creating build/lib/asyncsteem
copying asyncsteem/init.py -> build/lib/asyncsteem
copying asyncsteem/blockchain.py -> build/lib/asyncsteem
copying asyncsteem/blockfinder.py -> build/lib/asyncsteem
copying asyncsteem/jsonrpc.py -> build/lib/asyncsteem
copying asyncsteem/nodesets.py -> build/lib/asyncsteem

2019-05-02 17:36:30 ☆ nickademous in ~/asyncsteem
± |master ?:3 ✗| → brew link python@2
Linking /usr/local/Cellar/python@2/2.7.16... 38 symlinks created

2019-05-02 17:40:09 ☆ nickademous in ~/asyncsteem/sample_code/flag-stream
± |master ?:8 ✗| → pip2 install asyncsteem
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting asyncsteem
Downloading https://files.pythonhosted.org/packages/e4/b7/d339315eb28731b15853c38b22aa8ac1fdf258c64e3aebae7ce22e08192a/asyncsteem-0.6.3.tar.gz
Requirement already satisfied: twisted in /usr/local/lib/python2.7/site-packages (from asyncsteem) (19.2.0)
Collecting datetime (from asyncsteem)
Downloading https://files.pythonhosted.org/packages/73/22/a5297f3a1f92468cc737f8ce7ba6e5f245fcfafeae810ba37bd1039ea01c/DateTime-4.3-py2.py3-none-any.whl (60kB)
100% |████████████████████████████████| 61kB 810kB/s
Requirement already satisfied: PyHamcrest>=1.9.0 in /usr/local/lib/python2.7/site-packages (from twisted->asyncsteem) (1.9.0)
Requirement already satisfied: zope.interface>=4.4.2 in /usr/local/lib/python2.7/site-packages (from twisted->asyncsteem) (4.6.0)
Requirement already satisfied: Automat>=0.3.0 in /usr/local/lib/python2.7/site-packages (from twisted->asyncsteem) (0.7.0)
Requirement already satisfied: hyperlink>=17.1.1 in /usr/local/lib/python2.7/site-packages (from twisted->asyncsteem) (19.0.0)
Requirement already satisfied: attrs>=17.4.0 in /usr/local/lib/python2.7/site-packages (from twisted->asyncsteem) (19.1.0)
Requirement already satisfied: incremental>=16.10.1 in /usr/local/lib/python2.7/site-packages (from twisted->asyncsteem) (17.5.0)
Requirement already satisfied: constantly>=15.1 in /usr/local/lib/python2.7/site-packages (from twisted->asyncsteem) (15.1.0)
Collecting pytz (from datetime->asyncsteem)
Downloading https://files.pythonhosted.org/packages/3d/73/fe30c2daaaa0713420d0382b16fbb761409f532c56bdcc514bf7b6262bb6/pytz-2019.1-py2.py3-none-any.whl (510kB)
100% |████████████████████████████████| 512kB 983kB/s
Requirement already satisfied: setuptools in /usr/local/lib/python2.7/site-packages (from PyHamcrest>=1.9.0->twisted->asyncsteem) (40.8.0)
Requirement already satisfied: six in /usr/local/Cellar/protobuf/3.7.1/libexec/lib/python2.7/site-packages (from PyHamcrest>=1.9.0->twisted->asyncsteem) (1.12.0)
Requirement already satisfied: idna>=2.5 in /usr/local/lib/python2.7/site-packages (from hyperlink>=17.1.1->twisted->asyncsteem) (2.7)
Building wheels for collected packages: asyncsteem
Building wheel for asyncsteem (setup.py) ... done
Stored in directory: /Users/nick/Library/Caches/pip/wheels/20/76/53/fe8b91adf29dfd2b821c1645c1061cac7e104df712e9ae7402
Successfully built asyncsteem
Installing collected packages: pytz, datetime, asyncsteem
Successfully installed asyncsteem-0.6.3 datetime-4.3 pytz-2019.1

2019-05-02 17:42:26 ☆ nickademous in ~/asyncsteem/sample_code/flag-stream
± |master ?:8 ✗| → pip2 install blockchain
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting blockchain
Using cached https://files.pythonhosted.org/packages/0b/85/ca826affaeaad16506d3b19525f18cf18de394d52d4a9e645ef7dc9d59a2/blockchain-1.4.4.tar.gz
Collecting enum-compat (from blockchain)
Using cached https://files.pythonhosted.org/packages/95/6e/26bdcba28b66126f66cf3e4cd03bcd63f7ae330d29ee68b1f6b623550bfa/enum-compat-0.0.2.tar.gz
Collecting future (from blockchain)
Using cached https://files.pythonhosted.org/packages/90/52/e20466b85000a181e1e144fd8305caf2cf475e2f9674e797b222f8105f5f/future-0.17.1.tar.gz
Requirement already satisfied: enum34 in /usr/local/lib/python2.7/site-packages (from enum-compat->blockchain) (1.1.6)
Building wheels for collected packages: blockchain, enum-compat, future
Building wheel for blockchain (setup.py) ... done
Stored in directory: /Users/nick/Library/Caches/pip/wheels/6e/d9/4f/65e76bdafa4f3a950c679c9d999664c604b33077b0a9d014e8
Building wheel for enum-compat (setup.py) ... done
Stored in directory: /Users/nick/Library/Caches/pip/wheels/b1/69/f4/229af6a49beece0f688c9c73d9188769b89e698361d21ce96a
Building wheel for future (setup.py) ... done
Stored in directory: /Users/nick/Library/Caches/pip/wheels/0c/61/d2/d6b7317325828fbb39ee6ad559dbe4664d0896da4721bf379e
Successfully built blockchain enum-compat future
Installing collected packages: enum-compat, future, blockchain
Successfully installed blockchain-1.4.4 enum-compat-0.0.2 future-0.17.1

2019-05-02 17:48:20 ☆ nickademous in ~/asyncsteem/sample_code/flag-stream
± |master ?:8 ✗| → which pip
/Users/nick/try-twisted/bin/pip

2019-05-02 17:49:08 ☆ nickademous in ~/asyncsteem/sample_code/flag-stream
± |master ?:8 ✗| → pip2 install python-dateutil
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting python-dateutil
Downloading https://files.pythonhosted.org/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl (226kB)
100% |████████████████████████████████| 235kB 1.5MB/s
Requirement already satisfied: six>=1.5 in /usr/local/Cellar/protobuf/3.7.1/libexec/lib/python2.7/site-packages (from python-dateutil) (1.12.0)
Installing collected packages: python-dateutil
Successfully installed python-dateutil-2.8.0

2019-05-02 17:50:01 ☆ nickademous in ~/asyncsteem/sample_code/flag-stream
± |master ?:8 ✗| → python2 flag_stream.py

Screen Shot 2019-05-02 at 6.05.29 PM.png

Update: almost there! Disregard the python 2, Just
found the new one:))
git clone https://github.com/scottyeager/asyncsteem3.git
cd asyncsteem3
python3 setup.py install

Installed /usr/local/lib/python3.7/site-packages/zope.interface-4.6.0-py3.7-macosx-10.13-x86_64.egg
Searching for six==1.12.0
Best match: six 1.12.0
Adding six 1.12.0 to easy-install.pth file

Using /usr/local/Cellar/protobuf/3.7.1/libexec/lib/python3.7/site-packages
Searching for setuptools==40.8.0
Best match: setuptools 40.8.0
Adding setuptools 40.8.0 to easy-install.pth file
Installing easy_install script to /usr/local/bin
Installing easy_install-3.7 script to /usr/local/bin

Using /usr/local/lib/python3.7/site-packages
Searching for idna==2.8
Best match: idna 2.8
Adding idna 2.8 to easy-install.pth file

Using /usr/local/lib/python3.7/site-packages
Finished processing dependencies for asyncsteem==0.5.2

pip3 install blockchain
pip3 install python-dateutil
pip3 install pyopenssl

2019-05-02 21:06:08 ☆ nickademous in ~/asyncsteem3/examples
± |master ✓| → python3 print_votes.py
:0: UserWarning: You do not have a working installation of the service_identity module: 'No module named 'service_identity''. Please install it from https://pypi.python.org/pypi/service_identity and make sure all of its dependencies are satisfied. Without the service_identity module, Twisted can perform only rudimentary TLS client hostname verification. Many valid certificate/hostname mappings may be rejected.
Unexpected exception from twisted.web.client.FileBodyProducer.stopProducing
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/Twisted-19.2.0-py3.7-macosx-10.13-x86_64.egg/twisted/protocols/policies.py", line 125, in connectionLost
self.wrappedProtocol.connectionLost(reason)
File "/usr/local/lib/python3.7/site-packages/Twisted-19.2.0-py3.7-macosx-10.13-x86_64.egg/twisted/web/_newclient.py", line 973, in dispatcher
return func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/Twisted-19.2.0-py3.7-macosx-10.13-x86_64.egg/twisted/web/_newclient.py", line 1657, in _connectionLost_TRANSMITTING
..
.
.
File "/usr/local/lib/python3.7/site-packages/Twisted-19.2.0-py3.7-macosx-10.13-x86_64.egg/twisted/internet/task.py", line 497, in stop
self._checkFinish()
File "/usr/local/lib/python3.7/site-packages/Twisted-19.2.0-py3.7-macosx-10.13-x86_64.egg/twisted/internet/task.py", line 507, in _checkFinish
raise self._completionState
twisted.internet.task.TaskStopped:
2019-05-02 21:12:54 ☆ nickademous in ~/asyncsteem3/examples
± |master ✓| → logout
Saving session...completed.

[Process completed]
o.k., I think I got it. Getting closer, can't wait to test this stuff out as soon as I get my service module identifier all straightened out! lol. Hope that is the last error, maybe tomorrow I figure it out?
I'm going to flag your post to see if this thing works!? lol Mine is still white on https, not sure?
ssl in python still not working?? latest log
Screen Shot 2019-05-02 at 10.34.12 PM.png
Python 2.7.16 (default, Mar 4 2019, 09:02:22)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

from OpenSSL import SSL
from OpenSSL import SSL
from twisted.internet import ssl, reactor
Update:
Will set up with pycharm and try again now that I got a better idea what is going on!
Screen Shot 2019-05-04 at 3.51.05 PM.png

Screen Shot 2019-05-04 at 4.50.26 PM.png
Now back to terminal! Wow!
Screen Shot 2019-05-04 at 5.00.31 PM.png
O.K. now looks like I must use actual Python 2.7 for Interpreter. Switched and pycharm installed blockfinder inherently! (like a charm) my bad! lol wow, what a rabbit hole this is turning out to be! What surprises lie next????? There is a storm right now so my internet is real bad!
Screen Shot 2019-05-04 at 5.49.36 PM.png
Finally i'm almost there, computer just crashed because two were running in the background! Good sign. Will see soon.

O.K. I see the problem, I still gotta get ssl working with twisted.
https://twistedmatrix.com/documents/12.0.0/core/howto/ssl.html

I found this, I guess I must merge these??(actually I think I have to merge the client code below!) Add my cert, sounds easy enough.
Screen Shot 2019-05-05 at 11.09.47 AM.png
https://certsimple.com/blog/localhost-ssl-fix
2019-05-05 12:16:36 ☆ nickademous in ~/PycharmProjects/flagstream/sample-code/flag-stream/keys
± |master ↑1 ↓2 S:387 U:367 ?:461 ✗| → openssl pkcs12 -in Certificates.p12 -out Certificates.pem -nodes
Enter Import Password:
MAC verified OK

split up my cert with text editor nano, with bag-attributes
2019-05-05 12:30:16 ☆ nickademous in ~/PycharmProjects/flagstream/sample-code/flag-stream/keys
± |master ↑1 ↓2 S:387 U:367 ?:461 ✗| → nano cert.pem

2019-05-05 12:31:14 ☆ nickademous in ~/PycharmProjects/flagstream/sample-code/flag-stream/keys
± |master ↑1 ↓2 S:387 U:367 ?:461 ✗| → nano key.pem

now make a directory for the keys , copy the cert and key in.

mkdir ~./localhost-ssl

Testing SSL with Node, Check! Nice, lol omg, think I'm on the right track!
2019-05-05 15:59:31 ☆ nickademous in ~
± |master ↑1 ↓2 S:387 U:367 ?:463 ✗| → http-server --ssl --cert ~/.localhost-ssl/cert.pem --key ~/.localhost-ssl/key.pem
Starting up http-server, serving ./public through https
Available on:
https://127.0.0.1:8080
https://10.0.1.8:8080
https://192.168.2.1:8080
Hit CTRL-C to stop the server
[Sun May 05 2019 16:07:35 GMT-1000 (Hawaii-Aleutian Standard Time)] "GET /" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Safari/605.1.15"
[Sun May 05 2019 16:07:40 GMT-1000 (Hawaii-Aleutian Standard Time)] "GET /favicon.ico" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Safari/605.1.15"
[Sun May 05 2019 16:07:40 GMT-1000 (Hawaii-Aleutian Standard Time)] "GET /favicon.ico" Error (404): "Not found"
Screen Shot 2019-05-05 at 4.11.31 PM.png
Screen Shot 2019-05-05 at 6.44.05 PM.png
Now just a matter of getting the code in this working ssl Twisted example script.

Sort:  

Note thatasyncsteem and asyncsteem3 are seperate code bases for seperate python versions. There are features in asyncsteem (for Python 2.x) that aren't (fully) ported to asyncsteem3 (Python 3.x). The code for t post was done with the Python2 version. I'm currently working on a new library, txjsonrpcqueue that is currently still in a state of flux but that aims to become a library that works on both Python2 and Python3, and on Python3 works with both Twisted and asyncio, until it is production ready, I keep main the Python2 codebase, and @scottyeager is the man to see about the Python 3 codebase.

If the Python2 code is running, there should be a log file where you can see what is going on.
If you have it running for more than an hour, and the stream of block is working OK, you should at least see lines something like this once an hour:

2019-05-06T04:00:11+0000 [asyncsteem#info] Blockchain time mark: '2019-05-06T04:00:00'

Are you seeing those?

The code of this post by the way is in the asyncsteem source tree under sample_code/flag-stream

Hope this helps

Note thatasyncsteem and asyncsteem3 are seperate code bases for seperate python versions. There are features in asyncsteem (for Python 2.x) that aren't (fully) ported to asyncsteem3 (Python 3.x). The code for t post was done with the Python2 version. I'm currently working on a new library, txjsonrpcqueue that is currently still in a state of flux but that aims to become a library that works on both Python2 and Python3, and on Python3 works with both Twisted and asyncio, until it is production ready, I keep main the Python2 codebase, and @scottyeager is the man to see about the Python 3 codebase.

If the Python2 code is running, there should be a log file where you can see what is going on.
If you have it running for more than an hour, and the stream of block is working OK, you should at least see lines something like this once an hour:

2019-05-06T04:00:11+0000 [asyncsteem#info] Blockchain time mark: '2019-05-06T04:00:00'

Are you seeing those?

The code of this post by the way is in the asyncsteem source tree under sample_code/flag-stream

Hope this helps

Thanks, I think it is just my dns, will try on a server with dns next! Wow, Will look at your new repo next!

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 63635.72
ETH 2597.20
USDT 1.00
SBD 2.91