[Q] [SL4A] Importing PHP or Python script from github to execute from command line - Android Q&A, Help & Troubleshooting

Hey all,
This is my first post here because I have been tearing my hair out trying to get this to work on my own, and I hope you all can help.
What I am trying to do is get either nest-api in PHP or pynest in python to run out of SL4A in order to control my Nest thermostat ultimately out of Tasker. Both are found on github, but I can't link to them as I apparently need ten posts to do so. So a google search for "nest-api github" and "pynest github" will have to do I suppose.
I have absolutely no issues getting either to run out of Terminal on my MacBook Air, but for whatever reading the SL4A shell seems to escape my understanding. I would rather have the PHP script work, as it has more options for things I can set, which I like. The problem is I have no idea where to put the nest.class.php on my phone in order for the PHP shell to reference it when running the example.php or any script I write myself. When I put both files in the sdcard/sl4a/scripts folder and try to run either from within either sl4a or sl4a's shell I get a call to undefined function error.
For the python script, I'm not sure how I need to import the module so that I can call it with nest.py at the beginning of my command line prompt and follow it up with the user name and password and so on. I've done everything including trying to create an .egg file, which I've since been told is not necessary, and that I simply have to put it in the /sl4a/scripts folder. That doesn't make sense to me though, as I needed to run the setup.py command on my computer in order to start using it, and the .egg file should be the equivalent of that on the phone, no?
So what I am looking for is the foolproof way to get either a php or python script running through the shell that isn't actually hooking into the Android environment at all, which is what all the writeups I have found in my searching seems to pertain to. Then eventually make sure that they are available in a way that Tasker can call them. I should also note that all this has been done in an emulator through eclipse until this point, as I didn't want to go screwing around with my brand new Nexus 4's file structure until I had the best practice perfected.
Do you helpful folk have any guidance, tips, or insight on how I can get that done? Of course I can provide any other information you might need.
Thanks in advance.

Nest Api on Android using SL4A
I spend hours yesterday trying to do this. Did you ever get some help or figured it out on your own?
I have no idea how to make it work with SL4A I have done this succesfully on my computer.
Hope you can help me.
heytcass said:
Hey all,
This is my first post here because I have been tearing my hair out trying to get this to work on my own, and I hope you all can help.
What I am trying to do is get either nest-api in PHP or pynest in python to run out of SL4A in order to control my Nest thermostat ultimately out of Tasker. Both are found on github, but I can't link to them as I apparently need ten posts to do so. So a google search for "nest-api github" and "pynest github" will have to do I suppose.
I have absolutely no issues getting either to run out of Terminal on my MacBook Air, but for whatever reading the SL4A shell seems to escape my understanding. I would rather have the PHP script work, as it has more options for things I can set, which I like. The problem is I have no idea where to put the nest.class.php on my phone in order for the PHP shell to reference it when running the example.php or any script I write myself. When I put both files in the sdcard/sl4a/scripts folder and try to run either from within either sl4a or sl4a's shell I get a call to undefined function error.
For the python script, I'm not sure how I need to import the module so that I can call it with nest.py at the beginning of my command line prompt and follow it up with the user name and password and so on. I've done everything including trying to create an .egg file, which I've since been told is not necessary, and that I simply have to put it in the /sl4a/scripts folder. That doesn't make sense to me though, as I needed to run the setup.py command on my computer in order to start using it, and the .egg file should be the equivalent of that on the phone, no?
So what I am looking for is the foolproof way to get either a php or python script running through the shell that isn't actually hooking into the Android environment at all, which is what all the writeups I have found in my searching seems to pertain to. Then eventually make sure that they are available in a way that Tasker can call them. I should also note that all this has been done in an emulator through eclipse until this point, as I didn't want to go screwing around with my brand new Nexus 4's file structure until I had the best practice perfected.
Do you helpful folk have any guidance, tips, or insight on how I can get that done? Of course I can provide any other information you might need.
Thanks in advance.
Click to expand...
Click to collapse

I read on ifttt that they are planning on integrating nest options there. SO that is an easier solution I hope happens soon. They said this fall (already gone) or winter they hope to add functionality to for Nest. <fingers crossed>

Related

[Q] Setting up the Android SDK in Ubuntu...

Ok, I'm sure this is been asked before and I'm sure there's references somewhere...I've looked for a couple of days and found what should be answers, but nothing is working like the instructions I've seen...
Here's the simple question; How do I get the Android SDK and Java JDK setup in Ubuntu? I've tried the sudo commands to get the JDK to install, not working for me (as Ubuntu tells me it can't find the files I'm looking for). I've tried moving the SDK into the Root Folder (in the File System area itself), don't have permissions even though I'm logged in as the administrator. I've tried getting the SDK Manager to run through Terminal (home/android-sdk-xxxxx_xxxx/tools/android), can't find the file in terminal, but it's there in the file system exactly where I'm pointing it to.
I'm very new to Linux, but if I'm going to do things that I want to do, I'm going to have to learn. For the most part, I'm prepared to read whatever I need to in order to learn from this, but I also know when I need to ask for some help here. It seems like every command shown to get this started is just not working in the partition I have setup for this. If anyone can help get me started, I'm sure I can pick the rest up along the way!
Thanks in advance!
Macrodroid said:
Ok, I'm sure this is been asked before and I'm sure there's references somewhere...I've looked for a couple of days and found what should be answers, but nothing is working like the instructions I've seen...
Here's the simple question; How do I get the Android SDK and Java JDK setup in Ubuntu? I've tried the sudo commands to get the JDK to install, not working for me (as Ubuntu tells me it can't find the files I'm looking for). I've tried moving the SDK into the Root Folder (in the File System area itself), don't have permissions even though I'm logged in as the administrator. I've tried getting the SDK Manager to run through Terminal (home/android-sdk-xxxxx_xxxx/tools/android), can't find the file in terminal, but it's there in the file system exactly where I'm pointing it to.
I'm very new to Linux, but if I'm going to do things that I want to do, I'm going to have to learn. For the most part, I'm prepared to read whatever I need to in order to learn from this, but I also know when I need to ask for some help here. It seems like every command shown to get this started is just not working in the partition I have setup for this. If anyone can help get me started, I'm sure I can pick the rest up along the way!
Thanks in advance!
Click to expand...
Click to collapse
I think you could possibly use part of the EasyDev-v6 script in the Development and just cut out everything after installing prerequesites. It probably installs the JDK and the SDK among everything else, and it probably wouldn't hurt with the other things that installs, too. Just cut out everything after the prerequesites (it's just a regular text file but it'll be easier to edit in Ubuntu with OpenOffice).
Also check out http://maketecheasier.com/install-android-sdk-in-ubuntu-karmic/2010/01/11. As far as I know it worked when I tried it.
roirraW "edor" ehT said:
I think you could possibly use part of the EasyDev-v6 script in the Development and just cut out everything after installing prerequesites. It probably installs the JDK and the SDK among everything else, and it probably wouldn't hurt with the other things that installs, too. Just cut out everything after the prerequesites (it's just a regular text file but it'll be easier to edit in Ubuntu with OpenOffice).
Also check out http://maketecheasier.com/install-android-sdk-in-ubuntu-karmic/2010/01/11. As far as I know it worked when I tried it.
Click to expand...
Click to collapse
Dude, thanks so much! That worked perfectly. Thanks!
Sent from my Froyo Tazz using XDA App
You're welcome!

Programming Java on NT-Including generating APKs

Programming Java on NT-Including generating APKs
I don't know anything about java but am trying to learn. Most of what I would like to create will be simple. It would be nice to be able to create APKs so I could pass on to others if I wished necessary.
I have not been very successful setting up a proper environment in windows or linux. There are numerous guides on the internet for each operating system. The problem is the world keeps revolving and by the time I find a guide and try to follow it to conclusion there have been changes that cause an incorrect environment which is unusable.
I remember programming on iPAQs (xscale-arm processor) both in c/c++ and c# on board the iPAQ. After looking around a little I have found several options for windows users (gui) and one for linux users (command line) to program on the NT in java.
I felt I should pass this information along for others. These will be listed windows Style(gui) first and then linux style(command line) last.
Windows Style environment(gui) :
Aide - https://play.google.com/store/apps/details?id=com.aide.ui&feature=search_result
Just install and you have a working environment which will compile android api10 example files with nearly no changes (example change=add res directory which had been left out of example). The only thing that was not apparent is to watch the notification area for any errors which give you the problem and how to correct them. Updates have been often and useful. My first choice for windows type (gui) environment. Check the web for more info and tutorials about this program.
Android Java Editor – https://play.google.com/store/apps/..._result#?t=W251bGwsMSwyLDEsImNvbS5hbmplZGkiXQ..
With this one I had to watch the video and pause it several times to decide how to get setup and use (no audio-just video). It works and creates APKs also but is a bit more involved and the learning curve of the program is higher due to no available directions.
Linux Style environment(command line):
Terminal IDE – https://play.google.com/store/apps/...cuside&feature=nav_result#?t=W251bGwsMSwyLDNd
Easy install, good tutorials, and very easy to learn. Can be used with a tether (wifi or cable) and telnet to use keyboard and screen from your pc. This one has updates since I downloaded and support is great. I couldn't get the software keyboard to work on stock 1.4.0 but works great in CM7. As a result I used hackers keyboard while on 1.4.0. Also creates APKs. Includes vim, Midnight Commander, etc. This is a thirty meg download and is twice that when installed but everything is installed in /data/apps/ folder so it had no impact on a stock 1.4.0 system.
Notes:
None of these require being rooted to setup and use. There are others but I have decided not to list them in this thread for various reasons. I feel I have chosen the easiest to get working and use and provide the end result of an APK if you desire.
I forgot to mention they are all free. I have just begun this project so I can't be any help on use of these programs or java. I'm just passing on information as I think others may find useful. The way I see this project is anything I learn (no matter how little) from this is added to my limited knowledge and certainly can't help.
Almost forgot, I use jota text editor to look at and create source files.https://play.google.com/store/apps/...51bGwsMSwxLDEsImpwLnNibG8ucGFuZG9yYS5qb3RhIl0.
Nvm, you're talking about developing for android on android
lufthanza said:
Nvm, you're talking about developing for android on android
Click to expand...
Click to collapse
Yes that is correct.

Android source code building/software development

I have been searching and searching much to no avail. Here is my dilemma: I'm interested in android development and have installed ubuntu Linux os along with other requirements outlined on the android source website but I'm having the most difficult time getting the git program to install. I constantly receive error after error. Python, jdk6, and make have all installed with no problems. Can someone point me in the direction of a step by step procedure for completely setting up my computer with the required programs necessary for android development. Any and all help is greatly appreciated!
Sent from my LG-P925 using xda premium
google developer page clearly says which packages to install and what to do, you can search here at xda too.
if you have any problem try:
remove ~/bin directory
remake it
redownload repo script
add PATH variable
chmod it for executable
remove workdir
remake workdir
cd to your working directory
init your source
linux is not about make it and it should work you need a lot of things to get by yourself and learn to pass through problems. personally I was noob too, and still think I am, but linux really learns thinking in pc usage, that's not windows "if you can't do anything, that's impossible", you just have to find other way
it will be hard to start without linux knowledge, try using it first for a month then start development. you'll also need some xml and makefiles editing to know.
what you'll need
if you have cyanogenmod sources it's easy, you probably have everything that's needed,
if you use google's, then it's harder, because you miss drivers, device tree can fit from cm but you need to edit it.
you can find usb connection setup painful with editing udev rules, but with some practise it will be easy.
and please, for everyone to know: don't PM me or ask for help, I'm not a support, just saying here something that could help and I'm not pro .

[Q] problems with android sdk

*RESOLVED*
ive searched to no prevail. id like to start developing apps but am having issues getting the environment set up. i have the jdk properly installed.
issue 1 (main \ major ):
ive installed the android sdk from multiple sources, but when i try to start sdk tools, the command prompt flashes/ opens briefly and i get this message:
"Failed to execute tools\android.bat:
The system cannot find the file specified."
do i need to change a PATH variable or something...
issue 2:
i cannot get eclipse to run. when i try to open the exe file ( because there is no short cut icon...?) it gives a message about not finding a companion library... ive try to change the properties in the file that is supposed to fix it, but it was already set the way its supposed to be. this is not major as i can use a different IDE.
so im completely lost as to th sdk tool. any help would be appreciated!
edit:
i just tried adding the file path to the android sdk ( PATH variable) and it still did not work... :/
i also just tried start the android,bat file and the cmd promt flashes briefly saying somthing about xcopy is not an operable command...etc couldnt read all of it...
btw im on windows 7 home premium
Please use the Q&A Forum for questions &
Read the Forum Rules Ref Posting
Moving to Q&A
Check if this can help you.
Actually, you don't need to configure environment variables. You only need to install Java SE, and Eclipse and Android SDK should work fine.
RoberGalarga said:
Check if this can help you.
Actually, you don't need to configure environment variables. You only need to install Java SE, and Eclipse and Android SDK should work fine.
Click to expand...
Click to collapse
well eclipse wont install either, it cant find some companion library.all i curently have is the java jdk and an IDE called intelliJ idea or something like that, nothing else will install...i had to add an environmental variable to get the java jdk to work on cmd. if you could give links to any files your using that would be of help. , that is if your on windows 7
Sure...
Eclipse
Android SDK
Follow the indications of my previous link
Word of caution
I hate to discourage anyone from following their hearts desires especially when it comes to software development. But I wanted to share some advice with you coming from an experienced software engineer. I've been developing software for over 15 years. My experience comes mainly from developing Windows desktop applications in C/C++. I've also been developing software using Java for several years so I'm by no means new to Java technology or development tools.
I've only recently started to develop for the Android platform. It didn't take me long to get started (i.e. get the development environment setup and start developing using the AVD manager) but as I dig into it I'm finding that the Android platform has become very much like developing Windows applications which is interesting to find because I really haven't done a lot of user interface development using Java. In the past my Java development projects have always been more back end server integration related to App Servers and database integration (i.e. Apache/Tomcat, JSP, Oracle, etc.).
I have seen user interface development libraries in Java such as Swing in the past but haven't had a real need for them. So to tell you the truth I can't say how much better or worse the Android SDK user interface libraries are than the traditional JDK 1.4 libraries.
All of this is to say that when I say this you know it's coming from someone that isn't just learning how to program. My advice to you is that if you haven't done much Java development in the past that Android development is not the place to start. You might want to start with the basics first like just setting up a simple Java program and learning the technology first before you jump head long into something.
I've done that more times than I can count in my long career and I can tell you from experience it's the surest way to fail before you get started.
thanks but...
RoberGalarga said:
Sure...
Eclipse
Android SDK
Follow the indications of my previous link
Click to expand...
Click to collapse
i tried to use those files, but still the same problem, they wont launch/ install...in your post it says to launch them from the folder, correct...? the problem is, THEY WONT LAUNCH AT ALL...no UI for anything, just a quick flash of the cmd window for both of them and a pop up window for eclipse...
***i wasnt yelling, just frustrated...
First. DELETE EVERYTHING FROM DOWNLOADED FILES TO EXTRACTED FILE GET RID OF ALL OF IT then clear trash can.
THen ensure the JDK is successfully installed by opening command prompt and typing "java -version" you should have build 1.7 or higher. If not, you may download it here http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u4-downloads-1591156.html
Download this http://developer.android.com/sdk/index.html and pick the one that has "Recommended" next to it.
after you have that downloaded. FOLLOW THE STEPS BELOW TO A T! NO SHORTCUTS WHAT SO EVER!
Then once everything is downloaded. simply FOLLOW ME again TO A T! and if you follow that you should get everything working. And seriously, FOLLOW IT TO A T! do not take shortcuts do not try to do more than one thing at a time just take it step by step. I had no problems getting it up and running by following that last link.
Hope that helps and BE PATIENT you will get to play around soon enough
elesbb said:
...Then once everything is downloaded. simply FOLLOW ME again TO A T! and if you follow that you should get everything working. And seriously, FOLLOW IT TO A T! do not take shortcuts do not try to do more than one thing at a time just take it step by step. I had no problems getting it up and running by following that last link.
Hope that helps and BE PATIENT you will get to play around soon enough
Click to expand...
Click to collapse
thank you very much. i have what i need now, although i think i figured out my problem...stupid me was viewing the archive for eclipse instead of extracting the files to a separate folder, where the shortcut appeared!. thank you as it was your instructions that led me to my problem.
tripartist1 said:
thank you very much. i have what i need now, although i think i figured out my problem...stupid me was viewing the archive for eclipse instead of extracting the files to a separate folder, where the shortcut appeared!. thank you as it was your instructions that led me to my problem.
Click to expand...
Click to collapse
hahaha!! Sometimes all we need to do is slow down and look at whats infront of us xD glad you got it figured out!
Samsung Galaxy S II not recognized on PC
I want to sync my PC with my Samsung Galaxy Skyrocket and put music on it, but the PC won't recognized the phone.
I have tried downloading and installing the driver, Kies, etc and still get the same error.
Can someone help me??
android.bat still not present
I went to the sdk site to download. I ran the exe file, says that it couldn't find the tool\android.bat file. Please help

[Q] Compiling help a noob.

Im writing a Network Scanner currently in Python/Kivy for Android. I could do everything i wanted if i could execute a Python module called Scapy from the shell(Obviously this is a rooted app), but unfortunately its not possible. Atleast not with alot of work and when the App is finished i dont want my users to have to go through installing countless dependencies to get it working!
I've stumbled along a little unix program called Arp-Scan but i cant find a port for Android. I'm not sure how to port this to Android so i can execute it from a shell.
I have no experience with compiling and needless to say this is frustrating the hell out of me! . This one little stumbling block has been plaguing me for 2 weeks. The rest i will be able to do in pure Python, namely PortScanning and such.
The way the Android OS works is that an APK is unable to use raw sockets. But you are allowed to run a shell as root.
I have the option to use Nmap but if there was ever to be a paid version of my app i would have to buy a license and i simply cant afford it.
All i need is to execute a program from shell: like Arp-Scan to obtain an IP and MAC from the LAN.
Any help will be greatly appreciated.
Thanks in advance.

Categories

Resources