TypeError:must be a string without null bytes, not str

1.9k views Asked by At

I am having trouble passing in a variable to an os.system call in python. I have the following code:

f1 = open("package.txt","r+")
for i in f1:
    os.system("adb shell dumpsys package %s" %i)

and in my package.txt I have the following containing inside:

com.android.customlocale2
com.android.gallery3d
com.android.calendar
com.android.dialer
com.example.android.apis
com.android.htmlviewer
com.android.location.fused 
com.android.backupconfirm  
jp.co.omronsoft.openwnn 
com.android.packageinstaller
com.cyanogenmod.filemanager
com.android.providers.userdictionary
com.android.providers.downloads.ui
com.android.externalstorage
com.android.providers.contacts
com.android.dreams.phototable
com.android.galaxy4

I want to pass in each of the following within the os.system call but I can not unfortunately have it so that it works as intended. When run the code gives me the error

TypeError:must be string without null bytes, not str

I have looked at other forums/questions on stackoverflow and they say to add an 'r' to the beginning of the os.system call but that unfortunately is not working.

0

There are 0 answers