Thomasmcdaniel -3 Newbie Poster

This script is suppost to autorun from the flash drive once it is inserted into the pc it needs to auto download files to a paticular folder called (MEDIA) And it is supposed to over write whatever is in the (MEDIA) folder and add the new content from the flash drive it is also supposed to start vlc player in full screen mode to play the (MEDIA) folder most of the media that will be played is jpeg and an ocassinal short animated video around 10 seconds long

If anyone can please help me make this work or modify this code for me i dont know what else to do were trying to make this work on ubuntu 10.04 im only newbie i have hardly any knowlege in doing any code please help

import time
import os
import threading
def wtl(string):
f = file("/home/revmedia/playerlog.txt","a")
f.write(string)
f.close()

f = file("/home/revmedia/playerlog.txt","a")
f.write("starting\n")
f.close()
class player(threading.Thread):
medir = ""
def init(self, d):
threading.Thread.init(self)
print d + " this is d"
player.medir = d
def run(self):
print os.popen("pwd").read()+" before error"
print player.medir
os.chdir(player.medir)
l = os.popen("ls").read().split("\n")
s = ''
for k in l:
if k != '':
s += "\""+ k + "\" "
f =("/home/revmedia/playerlog.txt","a")
f.write("vlc -L -f " + s)
f.close()
os.system("vlc -L -f " + s)
class player2(threading.Thread):
medir = ""
def init(self, d):
threading.Thread.init(self)
print d
player2.medir = d
def run(self):
os.chdir(player2.medir)
l = os.popen("ls").read().split("\n")
os.system("rm -r /home/revmedia/media")
os.system("mkdir /home/revmedia/media")
for k in l:
f = file("/home/revmedia/playerlog.txt","a")
f.write(os.popen("sudo cp \""+player2.medir + k + "\" /home/revmedia/media/").read())
f.write(os.popen("sudo chmod -R 777 /home/revmedia/media").read())
f.close()
start = player("/home/revmedia/media")
start.start()
config = file("/home/revmedia/Desktop/flashdriveplayer.config","r")
options = config.read()
options = options.split("\n")
mode = False
starting = False
if options[0].find("yes") != -1:
mode = True

os.chdir("/media")
oldfolders = os.popen("ls").read().split("\n")
started = False
os.chdir("/home/revmedia/media")
t = None
x = 0
if os.popen("ls").read() != '':
time.sleep(30)
started = True
t = player("/home/revmedia/media")
t.start()
while True:
os.chdir("/media")
folders = os.popen("ls").read().split("\n")
newfols = []
if oldfolders != folders:
for k in folders:
found = False
for kk in oldfolders:
if k == kk:
found = True
if found == False:
newfols.append(k)
for k in newfols:
os.chdir("/media")
print os.popen("pwd").read()
os.chdir(k)
fols = os.popen("ls").read().split("\n")
found = False
for kk in fols:
if kk == "media":
found = True
if found == True:
di = "/media/" + k + "/" + "media/"
if mode == False:
t = player(di)
t.start()
os.chdir("/media")
while(os.popen("ls").read().find(k) != -1):
time.sleep(3)
os.system("sudo pkill vlc")
else:
if mode == True and started == False and starting == False:
started = True
wtl("****a\n")
print x200
x += 1
t = player2(di)
t.start()
starting = True
elif mode == True and started == True and starting == False:
os.system("sudo pkill vlc")
wtl("******b\n")
print x
200
x += 1
t = player2(di)
t.start()
starting = True
oldfolders = folders
time.sleep(30)
if (os.popen("ps -e").read().find("vlc") == -1 and started == True ) and starting == False:
started = False
if os.popen("ps -e").read().find(" cp\n") == -1:

wtl("no longer starting \n")

starting = False

TrustyTony commented: Badly indented code -3