bubbah12 wrote:Thank you for that. But if I wanted to place the variable in the line below, how would it be constructed?
graphicsmagick = "cp /home/pi/temp_montage3.jpg (Variable_name).jpg"
Create your filename as pcmanbob said above, modify the time string according to how you want it formatted - I've given it in the order that will appear oldest first when listed alphabetically (numerically) - year-month-day-hour-minute-second. This will give you a filename similar to
image1-2016-07-13-20-33-12.jpg
Code: Select all
filename = "image1-%s.jpg" % time.strftime("%Y-%m-%d-%H-%M-%S")
graphicsmagick = "cp /home/pi/temp_montage3.jpg %s" % filename
bubbah12 wrote:
I also wanted it to go into an ftp line:
with open('(variable name)', 'r') as f:
ftp.storlines('STOR %s' % '(variable name)', f)
ftp.quit()
Sorry for sounding so vague. I'm learning as I go...Or trying to:)
Create the string in the same way here - your version is almost there. Although if you're ftping an image you may want to use
ftp.storbinary() rather than
ftp.storlines() since the data isn't ASCII (and open the file with
'rb').
Code: Select all
with open(filename, 'rb') as f:
ftp.storbinary('STOR %s' % filename, f)
ftp.quit()