ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello:
I'm new in this forum as with Linux as well. I'm trying to set up an instant reply system using a raspberri pi3 and the pi camera. I already have the main stuff done, but with the code I will need some help from you guys!
This code is already in youtube https://www.youtube.com/watch?v=-QyMxKfBaAE from a guy that use it for the same pourpose that me. My problem is at the moment of run the code in the cmd prompt. there is a syntax error message specifically in the line #42
while not dircreated: if os.path.exists(directory): #add suffix and check again dirsuf = dirsuf + 1 directory = dirpref + "/" + str(dirsuf) + "/" else: #create directory os.makedirs(directory) dircreated = True
camera.start_preview()
here is the complete code in case someone of you can revise it and tell me what is wrong with it.
Hi, I've moved your question to the Programming forum to gain it better exposure.
I've also removed your personal email. The intents of the LQ site are that your questions are public and so are the answers so that others may benefit from seeing you work out the solution to your problem, much like the reference link you found to gain this code and start with your efforts.
Finally, I've added [code][/code] tags around your code to place it within a code block. This helps to retain the formatting. Meanwhile the formatting is likely gone when you pasted it inline. If you wish you can edit your original post to past in the code to recover the spacing and formatting.
Sorry I don't have a solution to propose, however my experience with the members from the Programming forum is that they likely will have a great deal of suggestions to help you with your syntax error and the remainder of your problem.
The OP did an inline paste of their code. All indenting was lost. I added the code block around it, however could not restore any formatting because none was in there as it was. We'll have to await their update to see if they can edit or post a new reply with properly formatted code inside code blocks.
>>> import time
>>> dirpref = time.strftime("%b%d%y")
>>> print (dirpref)
Feb2318
>>> directory = dirpref + "/"
>>> print (directory)
Feb2318/
>>> dircreated = False
>>> import os
>>> while not dircreated:
... if os.path.exists(directory):
... print ("yes")
... else:
... print ("no")
no
Clean that up, so that you can see what you are doing
Code:
while not dircreated:
if os.path.exists(directory):
do something
else:
do something else
#Something like:
while not dircreated:
if os.path.exists(directory): #add suffix and check again
dirsuf = dirsuf + 1
directory = dirpref + "/" + str(dirsuf) + "/"
else:
os.makedirs(directory) dircreated = True #create directory
camera.start_preview()
Also you can't put remarks at the front of a line like that.
You'll remark the whole line.
thanks to every one that spend some time trying to help me.
A i said before, i' m not experinced with linix and sorry for the mess withe code.
I just copy and paste it from the youtube link where I found it.
so formating means to break the lines as you guysmention above?
Can someone re write the whole code as it should be to see if it works?
thanks for the time of all of youguys and ! que viva el hobbie!!!😆🚀
Asking others to rewrite and test code that you have downloaded from some random place on the interwebs is not appropriate here at LQ. Please review the Site FAQ for guidance in posting your questions and general forum usage.
Python code depends on correct indentation as a core part of its "meaning". Multiple examples of code, identical except for the way they are indented, may all run but will produce different results. As no one here can say how the original author intended it to be indented, no one can offer useful help for oyur question.
I would suggest that you return to the place you got the code and ask for help, or at least try to get a working code example.
If you pay a girl/guy here 300$ per hour, they will work for you. Else, ask for a kindly help for some details. (My recommendation since I spent already few hours in that nice forum.)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.