Author

Topic: [SOLVED] armoryd.py missing import NameError; global name 'ServiceProxy' (Read 193 times)

newbie
Activity: 13
Merit: 0
I confirm that copying the old bitcoinrpc_jsonrpc from etotheipi's repo does the trick!

Maybe we should add it to the current version and add to the README that it has to be copied over in the BitcoinArmory root (if user decides to copy over the armoryd.py + txjsonrpc/.) or to root of armoryd as you mentioned  and then make a minor release?

newbie
Activity: 13
Merit: 0
Hi. Just FYI, I'll be gone for a few days, and my laptop will be in the shop anyway.

Now then, you've come across something interesting. ServiceProxy is actually from here. (It's still in etotheipi's original repo here.) For some reason, the reference to Jeff's code was removed four years ago. I still got armoryd to work somehow. Now, when I run it on a fresh VM, it chokes.

Here's what I propose. Copy the bitcoinrpc_jsonrpc folder from etotheipi's repo into the root armoryd direction. Then, in armoryd.py, add "from bitcoinrpc_jsonrpc import ServiceProxy" below the "import sys" line. It works for me. If it works for you, I'll open a PR. I noticed a couple of minor bugs that need to be fixed anyway.
.

Great!!! Thanks for the help there droark, I'll confirm that it works with the bitcoinrpc_jsonrpc folder and close the topic if it does!

The BitcoinThat was my original impression at the very beginning, but at the same time wasn't sure as it could have definitely only been for some old bitcoind rpc calls done in armoryd back then.

I think to answer your question, you might of installed the proper old jsonrpc libs back in the days in your python scripts paths and looks for it there? Otherwise I'm not too sure.

I'd be more than happy to contribute to the project if I find anything else that seems odd/weird. Also maybe extend the features ... I'll do a pull request if so.

Thanks,
sr. member
Activity: 525
Merit: 282
Hi. Just FYI, I'll be gone for a few days, and my laptop will be in the shop anyway.

Now then, you've come across something interesting. ServiceProxy is actually from here. (It's still in etotheipi's original repo here.) For some reason, the reference to Jeff's code was removed four years ago. I still got armoryd to work somehow. Now, when I run it on a fresh VM, it chokes.

Here's what I propose. Copy the bitcoinrpc_jsonrpc folder from etotheipi's repo into the root armoryd direction. Then, in armoryd.py, add "from bitcoinrpc_jsonrpc import ServiceProxy" below the "import sys" line. It works for me. If it works for you, I'll open a PR. I noticed a couple of minor bugs that need to be fixed anyway.
newbie
Activity: 13
Merit: 0
@goatpig @droark

was this of any help ? I get that the ./armoryd/txjsonrpc/ is good to go once copied, however does it assume there's a specific json rpc version pre-installed on the system?

Also, if either one of you could point to the class implementing ServiceProxy (in which file/lib even), I could probably take it from there. I was hoping to get this up by Wednesday to show a friend, but I'm running out of time/luck on this.

Let me know, I'm eager to fix this and open to any other mean of communication that would be more direct and/or interactive if you are OK with this.

Thanks!
newbie
Activity: 13
Merit: 0
here's what I've tried tonight:

Code:
~/BitcoinArmory$ python2 armoryd.py --regtest getarmorydinfo
Traceback (most recent call last):
  File "update_version.py", line 14, in
    f = open(hash_loc, "r")
IOError: [Errno 2] No such file or directory: '.git/91a3137ef1056e15cc606a186b0e508f84c'
/~
(ERROR) ArmoryUtils.py:3723 - Unsupported language  specified. Defaulting to English (en)
(WARNING) armoryd.py:3489 - http://:@127.0.0.1:18225 [i][b]#Yes I've added a printout here to try confirm the .conf worked as expected. Not sure where these credentials are actually used by the server instance of armoryd[/b][/i]
(ERROR) Traceback (most recent call last):
  File "armoryd.py", line 3630, in
    rpc_server = Armory_Daemon()
  File "armoryd.py", line 3125, in __init__
    self.executeCommand()
  File "armoryd.py", line 3490, in executeCommand
    proxyobj = ServiceProxy("http://%s:%[email protected]:%d" % \
NameError: global name 'ServiceProxy' is not defined

Traceback (most recent call last):
  File "armoryd.py", line 3630, in
    rpc_server = Armory_Daemon()
  File "armoryd.py", line 3125, in __init__
    self.executeCommand()
  File "armoryd.py", line 3490, in executeCommand
    proxyobj = ServiceProxy("http://%s:%[email protected]:%d" % \
NameError: global name 'ServiceProxy' is not defined


#### Here's a sanitized version of the armorylog.txt that was generated for that attempt specifically (path changed to ~ and username:password replaced by :

Code:
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1154 - C++ block utilities loaded successfully
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:679 - Executing popen: free -m
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:679 - Executing popen: ['cat', '/proc/cpuinfo']
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1271 -
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1272 -
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1273 -
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1274 - ************************************************************
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1275 - Invoked: armoryd.py --regtest getarmorydinfo
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1276 - ************************************************************
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1277 - Loading Armory Engine:
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1278 -    Armory Version        : 0.96.4
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1279 -    Armory Build:         : None
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1280 -    PyBtcWallet  Version  : 1.35
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1281 - Detected Operating system: Linux
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1282 -    OS Variant            : Ubuntu-18.04-bionic
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1283 -    User home-directory   : ~
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1284 -    Satoshi BTC directory : ~/.bitcoin/regtest
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1285 -    Armory home dir       : ~/.armory/regtest
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1286 - Detected System Specs    :
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1287 -    Total Available RAM   : 7.68 GB
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1288 -    CPU ID string         : Intel(R) Core(TM) i5-7260U CPU @ 2.20GHz
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1289 -    Number of CPU cores   : 4 cores
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1290 -    System is 64-bit      : True
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1291 -    Preferred Encoding    : UTF-8
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1292 -    Machine Arch          : x86_64
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1293 -    Available HDD (ARM)   : 433 GB
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1294 -    Available HDD (BTC)   : 433 GB
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1295 -
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1296 - Network Name: Regtest Network
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1297 - Satoshi Port: 18444
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1298 - Do wlt check: True
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1299 - Named options/arguments to armoryengine.py:
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     force_segwit    : False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     nettimeout      : 2
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     rescan          : False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     force_fcgi      : False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     ignoreAllZC     : False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     rescanBalance   : False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     disableModules  : False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     port            : None
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     interport       : 8224
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     coverageOutputDir: None
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     forceWalletCheck: False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     regtest         : True
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     rebuild         : False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     thread_count    : -1
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     datadir         : DEFAULT
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     clearMempool    : False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     offline         : False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     armoryDBDir     : DEFAULT
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     armorydb_port   : 9001
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     satoshiPort     : DEFAULT
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     disableConfPermis: False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     useTorSettings  : False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     netlog          : False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     keypool         : 100
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     coverageInclude : None
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     forceOnline     : False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     disableWalletCheck: False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     redownload      : False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     rpcBindAddr     : 127.0.0.1
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     armorydb_ip     : 127.0.0.1
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     multisigFile    : DEFAULT
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     ram_usage       : -1
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     ignoreZC        : False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     logDisable      : False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     settingsPath    : ~/.armory/regtest/ArmorySettings.txt
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     language        : en
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     db_type         : DB_FULL
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     doDebug         : False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     enableDetSign   : True
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     mtdebug         : False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     testnet         : False
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     rpcport         : DEFAULT
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     satoshiHome     : DEFAULT
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     satoshiRpcport  : DEFAULT
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     logFile         : ~/.armory/regtest/armoryd.py.log.txt
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1301 -     verbosity       : None
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1302 - Other arguments:
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1304 -     getarmorydinfo
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1305 - ************************************************************
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:1708 - C++ block utilities loaded successfully
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:3566 - Using settings file: ~/.armory/regtest/ArmorySettings.txt
2018-07-01 23:16:12 (ERROR) -- ArmoryUtils.py:3723 - Unsupported language  specified. Defaulting to English (en)
2018-07-01 23:16:12 (INFO) -- ArmoryUtils.py:3726 - Using Language: en
2018-07-01 23:16:12 (INFO) -- BDM.py:361 - Using the asynchronous/multi-threaded BlockDataManager.
2018-07-01 23:16:12 (INFO) -- BDM.py:362 - Blockchain operations will happen in the background.  
2018-07-01 23:16:12 (INFO) -- BDM.py:363 - Devs: check TheBDM.getState() before asking for data.
2018-07-01 23:16:12 (INFO) -- BDM.py:364 - Registering addresses during rescans will queue them for
2018-07-01 23:16:12 (INFO) -- BDM.py:365 - inclusion after the current scan is completed.
2018-07-01 23:16:12 (WARNING) -- armoryd.py:3489 - http://:@127.0.0.1:18225
2018-07-01 23:16:12 (ERROR) -- Traceback (most recent call last):
  File "armoryd.py", line 3630, in
    rpc_server = Armory_Daemon()
  File "armoryd.py", line 3125, in __init__
    self.executeCommand()
  File "armoryd.py", line 3490, in executeCommand
    proxyobj = ServiceProxy("http://%s:%[email protected]:%d" % \
NameError: global name 'ServiceProxy' is not defined



What am I missing?
newbie
Activity: 13
Merit: 0
Try running python2. Somewhere along the way, I think Ubuntu switched the default such that python invokes python3. I know that's the case on Macs using brew and am pretty certain Linux distros are going in that direction if they haven't already.

I'm running python 2.7 for sure. This is my dev environment and all of my projects are in 2.7 still (sadly ? :/)

1) Where are you getting armoryd from?

2) Post armorylog.txt

3) What version of Python are you running?

1) I cloned it from the repo: https://github.com/goatpig/armoryd.git As mentioned the first instance that is used as the server works like a charm and can interact with bitcoind no problem.
2) Will do. Currently out of the country and don't have ssh into the box
3) Running python 2.7
sr. member
Activity: 525
Merit: 282
Try running python2. Somewhere along the way, I think Ubuntu switched the default such that python invokes python3. I know that's the case on Macs using brew and am pretty certain Linux distros are going in that direction if they haven't already.
legendary
Activity: 3766
Merit: 1364
Armory Developer
1) Where are you getting armoryd from?

2) Post armorylog.txt

3) What version of Python are you running?
newbie
Activity: 13
Merit: 0
No luck ... Though it could have been related to qt4reactor given goatpig mentioned twisted, but didn't change anything.

ServiceProxy() doesn't seem to be part of Twisted either ... My guess is it would be within the JSON RPC library itself, but from my understanding I only need to copy the txjsonrpc into the /BitcoinArmory directory. That doesn't seem to do the trick. Looking up online for ServiceProxy(url) pretty much always yields results related to a jsonrpc, but still can't find it within the txjsonrpc folder included in the source of armoryd. Do I need to do anything else regarding json rpc libs (other than copy the directory to the other location)?
newbie
Activity: 13
Merit: 0
so apt-get is still stuck on the older version of  twisted, however even with the current installed through pip, rebuilding and trying again I'm still getting the same error on the 2nd instance (1st instance aka server works like a charm) trying to run python armoryd.py --regtest
newbie
Activity: 13
Merit: 0
Thanks for the quick replies @goatpig & @droark. It's appreciated.

Also, please make sure you're running the latest version. It's here. There's a README here that hasn't been pulled in yet but it should cover many, if not all, of the questions you might have.

I do have this version and went through the specified README; I had done the exercise going the pull requests on top to try to get more info in case a new version was pushed in some non-master branch, but the only one available for armoryd was indeed master. I must say this new README provides extra details and was welcome, but didn't solve that specific issue. I've got the username:password added in a armoryd.conf that lives in /.armory/regtest/ ... I've even modified the code to print out that it grabs the proper username, password, RPC_PORT prior to executing:
 
Code:
ServiceProxy("http://%s:%[email protected]:%d" user, pw, RPC_PORT)

Do you have python twisted installed?


I do! Everything else seems fine with it. Currently on 17.9.0-2 ... I assume this ServiceProxy calls resides within python-twisted if you're asking [and not the bitcoin rpc libs]? I see they've released two versions since this one ... I'll try moving to the latest (18.4.0) as of April 2018, rebuild and try again. I will come back to report on the results.
sr. member
Activity: 525
Merit: 282
Also, please make sure you're running the latest version. It's here. There's a README here that hasn't been pulled in yet but it should cover many, if not all, of the questions you might have.
legendary
Activity: 3766
Merit: 1364
Armory Developer
Do you have python twisted installed?
newbie
Activity: 13
Merit: 0
I'm trying to run armoryd.py locally as a server (1st instance, no issue, runnnig as --regtest, ArmoryDB & bitcoind are also up and working) and then in a separate terminal trying basic calls in the following way:

$ python armoryd.py --regtest getarmorydinfo
So far, it's pretty straight forward, however I always end up with an error when armoryd is calling executeCommand() at line 3489;
Code:
Name Error: global name 'ServiceProxy' is undefined.

I see from version 0.93.3 that there use to be the following import in various files (SDM, armoryd, etc.):
Code:
from bitcoinrpc_jsonrpc import ServiceProxy
Is this still relevant? Is it missing from the txjsonrpc libraries somehow ? Now I tried to look in the different imports from txjsonrpc and couldn't find it in there. Any idea which import hasn't work properly? Any other idea of why this wouldn't work? I did indeed copy armoryd.py and the txjsonrpc/ to the BitcoinArmory directory. I also create an armoryd.conf with a random username:password in the default armory home dir ~/.armory ... this shouldn't be the issue in my opinion as we're alreayd facing the issue as we call ProxyService()

Thanks in advance to anyone who can assist on this 1, should be pretty straightforward
Jump to: