What's the difference between these two python scripts?


code: [select]

file script = filesystem.open("/tmp/example.py", file_write);
script.print("#!/usr/bin/python\n");
script.print("import urllib\n");
script.print("import ast\n");
script.print("r = urllib.urlopen('https://api/fields=transaction_sold_count&api_key=asdfasdfasdf')\n");
script.print("a = r.read()\n");
script.print("y = ast.literal_eval(a)\n");
script.print("b = y[]\n");
script.print("print b"); //should print int
script.close();


and

code: [select]

file script = filesystem.open("/tmp/example.py", file_write);
script.print("#!/usr/bin/python\n");
script.print("a = 394079273014\n");
script.print("print a");
script.close();


note: both these scripts set executable , linux "cat" process shows both input python script file without error. run process:

code: [select]

process reading;
reading.begin("/tmp/example.py");
reading.run();

string output;
while(reading.available())
{
 output += (char)reading.read();
}
serial.println(output);


the latter, more simple example.py script runs flawlessly , prints serial monitor, while former doesn't output anything. i'm really, confused this. i've run them both in osx terminal , both run there too. imported modules in former not included yun's version of python? leads appreciated!

at mac terminal:

code: [select]
ssh root@arduino.local

password: arduino

please test @ linino console. post error code here.


Arduino Forum > Products > Arduino Yún (Moderator: fabioc84) > What's the difference between these two python scripts?


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support