Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pysftp
- import time
- import os
- import subprocess
- # call this to send music files over
- def send_audio_file(path):
- with pysftp.Connection('192.168.0.103', username='pi', password='raspberry') as sftp:
- with sftp.cd('/home/pi/play_this'):
- with open(path + '.ready', 'w') as readyfile:
- readyfile.close()
- sftp.put(path)
- sftp.put(path + '.ready')
- send_audio_file('movement.mp3')
- # run on the pi
- def receive():
- p = subprocess.Popen(['echo', 'Running dumbstreamer'])
- running = ''
- while True:
- if p.poll() is not None: # not playing the audio
- if running is not '': # something just finished
- os.remove(running)
- os.remove(running + '.ready')
- running = ''
- for file in os.listdir('/home/pi/play_this'):
- if '.ready' in file:
- file = file.replace('.ready', '')
- p = subprocess.Popen(['mpg123', file])
- running = file
- time.sleep(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement