Piston on Windows 7

in #piston8 years ago (edited)

Piston is command line tool and library written in python for interact with steem directly. Made by @xeroc.

I'm talking about:

  • steem-piston 0.2.3
  • python 3.5.2
  • windows 7 x64

piston robot

Install python from python.org

  • check "Add python to PATH"

Before installing piston we need to prepare modules for work on windows architecture. Visual Studio need for compile python module scrypt needed for piston.

Install Visual Studio 2015 community from microsoft

  • select C++ and python tools

Install WinOpenSSL from slproweb.com

  • Select 64bit or 32bit arch, depend on you version of Windows
  • remember the directory, where you place OpenSSL
  • I'm select "place openssl dll into windows directory"

Prepare and build scrypt python module

Download and unzip scrypt module from bitbucket. Enter to directory (mhallin-py-scrypt-119842611360 in my case) and open

setup.py

with you preferred text editor (notepad work).

Now we need to change path's if we have windows 64bit and we download OpenSSL 64bit. Search string sys.platform.startswith('win32'): and replace "32" with "64" to look like this:

elif sys.platform.startswith('win32'):
    define_macros = [('inline', '__inline')]
>    library_dirs = ['c:\OpenSSL-Win64\lib']
    libraries = ['libeay32', 'advapi32']
>    includes = ['c:\OpenSSL-Win64\include', 'scrypt-windows-stubs/include']
  • Symbol ">" just marking lines to change, do not enter it.
  • Remember to change c:\OpenSSL-Win64 to directory where you install it if you change the default.

After that we need to add magic "to prevent from duplicate type error" to file

\scrypt-1.1.6\lib\scryptenc\scryptenc_cpuperf.c

Search for "#ifdef _WIN32" and append before and after #ifdef block:

>#ifdef HAVE_STRUCT_TIMESPEC
#ifdef _WIN32
struct timespec {
       time_t tv_sec;
       long tv_nsec;
};
#endif
>#endif
  • again, do not enter character ">", it just for mark

Ok, now we good to build and install. Return to directory with setup.py and run

python setup.py build
python setup.py install

Prepare and build winrandom-ctypes

After that we can install piston with pip, but wallet will not going to work. We need winrandom module, but that module not work with python 3. We have an alternative module - winrandom-ctypes. Let do magic again:

  • I'm talking about winrandom-ctypes-1.0

Download winrandom with command pip download winrandom-ctypes and unzip it. Enter to directory winrandom-ctypes-1.0/winrandom and open file

init.py

The file has only three strings , and it should look like this:

>from .ctyped_funcs import get_bytes as bytes
>from .ctyped_funcs import get_long as long

VERSION = '1.0'

Add a point before "ctyped_funcs" in first and second line and save file.

  • do not forget not to enter the symbol ">" in beggining of strings, it just for mark what string are changing.

Installing other modules

Now we ready to do pipping:

pip install steem-piston

Fixing module Crypto

Do not know what the heck with that module (most likely python 2 to 3 stuff), but we need to add point in file

C:\Python35\Lib\site-packages\Crypto\Random\OSRNG\nt.py

__revision__ = "$Id$"
__all__ = ['WindowsRNG']

>from . import winrandom
from .rng_base import BaseRNG

class WindowsRNG(BaseRNG):

Add a point and space before import and we good to go.

Running piston.exe

If we checked "add python to PATH" than we might run piston from everywhere:

piston addkey you-private-key-from-steemit-for-posting

After that you need to enter passphrase for you wallet, and enter it everytime when you start piston.

So, we can do stuff, look to quick start from piston.rocks or readthedocs about APP

Encoding issue

If we try to list posts, and some of titles contain UTF-character:

piston --list

we can end up with trouble about charmap, encoding and other UTF-realted stuff.
Before we try to run that command we need to setup console encoding by:

set PYTHONIOENCODING=utf-8

Time synchronization

If our clock is not properly cynchronized, than we got ugly error on upvoting posts (or doing any other thing) about "now < trx.expiration: on apply transaction"

Set you clock correctly (Internet time in date/time configuration).

Other troubles

Write in comments what going wrong in you case.

Sources

Writing that post in that Markdown Editor

Sort:  

nice tutorial ... thanks @etz ... but piston for what ??

Hehe, forgot to mention :) It's command line tool and library written in python for interact with steem directly. Made by @xeroc

Coin Marketplace

STEEM 0.23
TRX 0.26
JST 0.040
BTC 98493.61
ETH 3483.79
USDT 1.00
SBD 3.28