Thread: Please Help

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    Unhappy Please Help


    I need some help im trying to get a script that will auto download media files from a flash drive to the hdd and auto start vlc player in full screen ill insert the flash drive it downloads and i remove it and the advertisements keep playing the slide show afterwards im using ubuntu 10.04
    Im helping a guy with digital signs and there going to be used as advertising kiosk if anyone can help me i have no coding experience what so ever
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,997
    Rep Power
    481
    I would use bash rather than python. If you used python you'd just end up calling the shell anyway.

    When I stick a usb into my computer it is the device /media/NANO
    If you have multiple usb sticks they'll probably get numbers.

    You'll need to know the file names. The bash command lists the directory:

    $ ls -R /media/NANO

    In my case I have a no doubt fully exciting movie
    /media/NANO/Reunion_2011/SANY0051.AVI

    I've chosen to store the files onto /tmp/NANO
    Next, do these commands by hand to make sure they work.
    mkdir will fail if you already have a NANO directory.
    you could remove it with
    rm -r /tmp/NANO
    or clean it with
    rm -r /tmp/NANO/*

    $ mkdir /tmp/NANO
    $ cp -r /media/NANO/* /tmp/NANO
    $ vlc --fullscreen file:///tmp/NANO/Reunion_2011/SANY0051.AVI

    vlc played the movie as expected, but produced a load of error messages that didn't look important.
    I vanquish the error output to /dev/null .
    You should first know what are your errors before you hide them.

    So you'd have a bash script that looks something like this. Use
    $ chmod +x thisscript.sh
    to make it executable.
    Then run it with
    $ thisscript.sh
    Code:
    #! /bin/bash
    
    # first I'll make a new directory in /tmp and copy the files there.
    
    mkdir /tmp/NANO
    cp -r /media/NANO/* /tmp/NANO
    
    # next run vlc
    # good grief, vlc has almost as many options as gcc.
    nohup vlc --fullscreen file:///tmp/NANO/Reunion_2011/SANY0051.AVI &>/dev/null &
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0
    man its all Chinese to me i don't know the first thing about code are how or where it goes i basically need something i can copy and paste into the bin folder and when i insert the flash drive it works hell i cant even figure out how to place what i do have in the bin the guy that was doing all this he is no longer here and none of us know how to do it if you could tell me step by step that would be great man sorry for the burden
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,997
    Rep Power
    481
    I'm available for hire.

    Lambert Electronics, LLC. USA, NY.

    b49p23tivg@stny.rr.com



    First, you'll need to open a terminal window into which you can enter commands.

    If you can find an "accessories" menu somewhere on your system, look down it until you see the "terminal" option.

    Once you have a terminal open it should hang there with a prompt of some sort. I write "dollar sign space character" to stand for the system prompt.

    Well, here you might just have to learn some unix commands.

    I recommend that you command your system prompt with

    info

    use the down arrow key to the "core utils" line
    Press return and read all of it.

    When you've gotten a system prompt and managed to issue a few commands write back and we'll take the next step.
    [code]Code tags[/code] are essential for python code and Makefiles!
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0
    This script is missing something it was working when the guy that was doing the coding was here he and his friend tried to modify it and make it better but all it needs to do
    1 insert flash drive and it downloads the media on the flash drive to a folder in the mother machine it needs to overwrite or delete files that are in the media folder
    2 It needs to auto launch the vlc player and play the slide show in full screen mode
    3 This all should take place just by inserting the flash drive and once the media starts on screen we pull out the flash drive and thats it





    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 x*200
    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

    Comments on this post

    • Lux Perpetua disagrees : Ever heard of punctuation? Or code tags?

IMN logo majestic logo threadwatch logo seochat tools logo