krushnakant
krushnakant

Reputation: 431

Run python Script in android application

I want to get list of installed software on remote computer.For that I want to use python script in my android application.Now,I have a python script which is getting the list of installed software on remote computer.But,I don't know how to make it supported in android.
For this, I found SL4A android Scripting here . So, I tried to run my python script in android device using SL4A.But,It's not working and giving me error because some packages like win32.client is missing.I don't know more about SL4A so I don't know how to convert my python script in Android supported form.So,anyone have any idea or code please suggest me.....

Also If anyone have another way to get installed software list from remote Pc then please suggest...
Below is my python script

import wmi
from winreg import (HKEY_LOCAL_MACHINE, KEY_ALL_ACCESS, OpenKey, EnumValue, QueryValueEx)

c = wmi.WMI(computer="PC02",user="admin",password="a@1",namespace="root/default").StdRegProv
result, names = c.EnumKey (hDefKey=HKEY_LOCAL_MACHINE, sSubKeyName=r"Software\Microsoft\Windows\CurrentVersion\Uninstall")

print('These subkeys are found under "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"\n\n')

separator = "*" * 80
keyPath = r"Software\Microsoft\Windows\CurrentVersion\Uninstall"
count = 0

while count < len(names):

    try:      
        print(separator+'\n')

        path = keyPath + "\\" + names[count]
        key = OpenKey(HKEY_LOCAL_MACHINE, path, 0, KEY_ALL_ACCESS)
        temp = QueryValueEx(key, 'DisplayName')
        display = str(temp[0])
        print (" Name: "+display+'\n',"key:",names[count])

        count += 1
    except:
        print ("Key:",names[count])
        count += 1
        continue

Upvotes: 2

Views: 4207

Answers (5)

Justcurious
Justcurious

Reputation: 2309

Running python scripts is now achievable in gradle system using Tasks

task pythonFile(type:Exec) {
workingDir 'src_path'
commandLine 'python', 'my_script.py'
} 

Upvotes: 0

rapadura
rapadura

Reputation: 5300

Run the script on your remote computer, and expose the list of installed software on HTTP, a good way to write this simple web app is to use flask and its development server to serve the list of installed software, then write a python script which uses the native android web interface to fetch the list and display it.

Upvotes: 3

Lie Ryan
Lie Ryan

Reputation: 64953

Since WMI is based on WBEM, you may be able to use wbem to access it; you might want to try using pywbem, a pure python wbem library.

Upvotes: 0

cha0site
cha0site

Reputation: 10737

You're trying to use a Python script that uses Windows Management Instrumentation (WMI), on a device that doesn't have that library.

Sadly, WMI on Python requires the win32 library, which is only available on Windows. I don't think you're going to have much success on checking the installed programs on remote Windows computer from an Android device in this way.

Upvotes: 1

Thoughtful Dragon
Thoughtful Dragon

Reputation: 260

You are having problems with missing libraries because you are importing windows specific ones. At any rate, this isn't the correct script to be running. This script seems to be for a computer, not an android phone.

Upvotes: 2

Related Questions