unable to print parameters in ArcGIS and arcpy - arcpy

I am beginner and created a python script tool in ArcMap and run to print input variables. I also opened python window in ArcMap. The script has not printed the variable values which entered in the tool at run time. Please suggest me.
import arcpy
fc = arcpy.GetParameterAsText(0)
dist = arcpy.GetParameterAsText(1)
print fc
print dist

You need to use
arcpy.AddMessage(fc) rather than print(fc)


why the doctest didn't work in qpython3

I'm trying to use doctest in qpython. But the script didn't work , which it it ok in PC enviroment.
It is just two line different with the my script in PC enviroment:
import sl4a
droid = sl4a.Android()
After run the script in qpython, I can see the log of docctest, but the test case seems not be tested. The msg I got is :
11 items had no tests:
0 tests in 11 items.
0 passed and 0 faied.
Test passed
Is there any important things I missed?
Thanks for your help!
That's because qpython runs python with optimization on (-OO), which removes docstrings, so doctest doesn't see anything.
The following trick gives you almost all functionality back.
Basically, it just parses the source file with the ast module to grab the docstrings and put then in the __test__ dictionary.
def setupDoctest():
global __test__
import ast
__test__ = {}
parsed = ast.parse(open(__file__).read(), "doctest")
doctypes = ast.Module, ast.FunctionDef, ast.ClassDef
for node in ast.walk(parsed):
if isinstance(node, doctypes):
d = ast.get_docstring(node, True)
if d:
__test__[getattr(node, "name", "module")] = d
Just call this before calling doctest.testmod, and it wil run the docstrings.
Maybe you found a solution, but I had a similar experience with QPython the other day. Seems you can not (yet) use Player or Pyjnius in the console with QPython. Running the script as a Kivy app makes imports of Plyer or Pyjnius work. Try adding the following lines:

Groovy using variable in import command

There was the same question for python language on the web-site, but I need to do the same thing in Groovy:
env = System.getenv("INSTANCE")
cp = ${env} + ".Vars"
import "${cp}"
This of course doesn't work, but is there a possibility to use a variable inside import command in Groovy? I'm a novice in Groovy and can't figure it out, googled a lot, but without any success. I will be very grateful to anyone who helps.
No you can not import via a string. But you can load your class there via Class.forName(cp) (then then use it e.g. via newInstance().

How to run monkeytalk scripts each time with new data?

We are using eclipse luna 4.4.1, adb is installed on linux system to test android app.
I have recorded a monkeytalk script. So my question is how to run that monkeytalk recorded script in 500 times. But in every loop the value of input data should be change(Validation stuff).
For example : I recorded sign up account. So that need to run it 500 times to create 500 diffrent account.
Thanks in advance.
You have to use parameterization.
It's simply when you use variables in your script instead of hardcoded values. That gives you an opportunity to assign new values to that variables with each new run.
Here is an example from official documentation regarding parametrizing the script:
Vars * Define usr="default-at-example.com" pwd
Input username EnterText ${usr}
Input password EnterText ${pwd}
Button LOGIN Tap
In this listing you can see that you've defined "usr" variable with default value ("default-at-example.com").
As a result, you can invoke you parametrized script in a number of different
In this case "pwd" variable will have "i like cheese" value:
Script login.mt Run joe-at-doe.com "i like cheese"
Following example shows script invocation without specifying any arguments for variables:
Script login.mt Run * password1
It'll have following effect: variable "usr" will have its' default value and "pwd" variable will have "password1" value
Don't forget that those variables' scope is limited only to the script. It means that they're visible and can be used only inside of script where they have been defined.
Moreover you can use external data sources in order to feed your tests with data. It's called data driven testing. Here is an example of script which uses *.csv file (coma separated) as such data source:
joe-at-doe.com, "i like cheese"
alpha-at-beta.net, password1
charlie-at-dog.org, abc123
In order to use such *.csv file just run following command:
Script login.mt RunWith data.csv

Is there a way to programmatically (or from the terminal) check whether any app engine indexes are building?

Our team does a lot of rapid iteration and deployment, and I'm trying to make it safer to deploy (knowing you won't bring down the site). I've implemented regular tests but one thing that's plagued us a few times is the site being deployed with queries based on new indexes that someone else has just deployed (but the indexes haven't finished building, so any page that uses them fails with a NeedIndexError).
I'm looking for a way to implement a check in our deploy script that will respond if any of the indexes are still building before if attempts the deploy.
Does anyone know if you can check this from the terminal or through some API? I've not had any luck finding one, and I'm hoping to not have to go down the route of scraping the App Engine console's indexes page to check for the word "building".
The following snippet will block until all indexes are done building. I use it before running update.
(In gist form: https://gist.github.com/jgeewax/5650457)
#!/usr/bin/env python
# Need to import and fix the sys path before importing other things.
import remote_api_shell
import time
from google.appengine.api import datastore_admin
from google.appengine.ext.remote_api import remote_api_stub
from google.appengine.tools import appengine_rpc
def configure_remote_api():
def auth_func():
'<APP_ID>', '/_ah/remote_api', auth_func,
save_cookies=True, secure=False,
def main():
print 'Checking indexes...'
interval = 10 # seconds.
building = True
while building:
# Start with a fresh run: maybe we're done building?
building = False
for index in datastore_admin.GetIndices('s~<APP_ID>'):
# If any single index is building, we're not done.
# Sleep for a bit and then this cycle should repeat.
if not index.has_state() or index.state() != index.READ_WRITE:
building = True
print 'Indexes are still building... Waiting %s seconds.' % interval
print 'All indexes are up to date.'
if __name__ == '__main__':
ok, I remembered something from the dim dark past. (You haven't said if your using python or java, so here is something to try with python).
google.appengine.api.datastore_admin has a number of methods related to information about indexes.
Specifically GetIndices call. I don't have any building indexes at the moment so I can't see exactly what state a building index is in. But have look below and you will get the idea.
Below is from a remote_api_shell session.
s~xxxx> from google.appengine.api import datastore_admin
s~xxxx> x=datastore_admin.GetIndices()
s~xxxx> x[0]
<google.appengine.datastore.entity_pb.CompositeIndex instance at 0x926fa2c>
s~xxxx> x[0].has_state()
s~xxxx> x[0].state()
s~xxxx> x[0].State_Name(x[0].state())
s~xxxx> print str(x[0])
app_id: "s~xxxx"
id: 1
definition <
entity_type: "Plant"
ancestor: false
Property {
name: "class"
direction: 1
Property {
name: "family"
direction: 1
Property {
name: "name"
direction: 1
state: 2
So with a bit of poking around you may well be able to see when an index stops building. At that point you can use appcfg to promote a specific version to default or kick off some tests for the new deployment etc....
Let us know what you see with index state against a building index.
For completeness I actually asked about getting the definition of indexes programatically back in 2009 and Nick Johnson alerted me to this capability. See groups post https://groups.google.com/forum/#!searchin/google-appengine/defined$20indexes/google-appengine/nCzSLJkoZuQ/X4GQ0GMBI0gJ

Embedding python error Import by filename is not supported

I'm trying to embed python in to my application and have got stuck pretty early on.
I am embedding python into my C++ application and using the code found at this tutorial:
My application matches entirely and compiles successfully no errors. However on running the application pModule = PyImport_Import(pName); line fails returning 0 meaning I get error output from PyErr_Print() of
Failed to load "C:\Users\workspace\dpllib\pyscript.py"
ImportError: Import by filename is not supported.
The application is being called with the commands C:\Users\workspace\ndnlib\pyscript.py multiply 50 150
I can't be sure, but I'm thinking that since pName is set to argv[1] and you're using the full path to call the script, then argv[1] is the full path. This means the code would try to import "C:\Users\workspace\dpllib\pyscript.py", which python can't (it can only import "pyscript").
Try running the script by just typing "pyscript.py" from within the directory and see if the error changes to 'Failed to load "pyscript.py"'. If it does, then you have to fix it so it doesn't just import argv[1] and modifies the string to get a module name instead of a file name.
It is simplier if you create your file as a module.
For instance,
create this:
Then run your file <project>/script.py
dyn_module_name = (... get module name 'MyModule' from console arguments ...)
my_dynamic_module = __import__(dyn_module_name)
Since it would be a module, it will load while your scripy.py execution