Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need Help for my program
#18
(Dec-24-2019, 05:08 AM)sampathkumar Wrote:
(Dec-06-2019, 12:16 PM)Malt Wrote: I can suggest you a logic, you can have a flag and make the flag to turn True when all the expected sub folders are available. Till then it has to keep checking the folders availability. Here we are having a check, when any folder creation fails then it will keep on waiting and checking endlessly.

To avoid that you can have a timer, either timer should expire or your condition should meet. After meeting either of the case, your next step which is copying the sub folders to another location should take place.

Thank u malt.
Can u write this script for me which will be useful.
Thanks in advance.


import os, sys
import os.path
import glob
import shutil
import time, datetime
import logging
from datetime import date, datetime, timedelta


parent_dir = "/home/user1/incoming/"
today = date.today()
folder1 = today.strftime("%Y-%m-%d")
directory_path = os.path.join(parent_dir, folder1)

def checking_folder():
    	folder_found = False
    	count = 0
    	folders_to_check = ['folder1','folder2','folder3','folder4']
	while not folder_found and count < 50:
		print("Checking folders existence")
		folder_path = os.path.join(parent_dir, folder1)
		print(folder_path)
		for folder in folders_to_check:
		    if os.path.exists(folder_path + folder):
		        print(f"Folder is identified: {folder}")
		        folder_found = True
	 
		    else:
		        print(f"This folder is missing: {folder}")
		        folder_found = False
		        count += 1
		        break

if os.path.exists(directory_path):
    print("Folder found")
    checking_folder()	
    
else: 
	print("Folder doesn't exists")
Dear mr. Malt
While running this code iam getting the following error msg:


File "final.py", line 25
print(f"Folder is identified: {folder}")
^
SyntaxError: invalid syntax


Pls help me correct this problem.....

Thanks in advance....
Reply


Messages In This Thread
Need Help for my program - by sampathkumar - Nov-27-2019, 05:22 AM
RE: Need Help for my program - by Malt - Nov-27-2019, 06:20 AM
RE: Need Help for my program - by sampathkumar - Nov-27-2019, 07:38 AM
RE: Need Help for my program - by Malt - Nov-28-2019, 08:31 AM
RE: Need Help for my program - by buran - Nov-27-2019, 07:54 AM
RE: Need Help for my program - by sampathkumar - Nov-27-2019, 09:21 AM
RE: Need Help for my program - by sampathkumar - Nov-29-2019, 07:18 AM
RE: Need Help for my program - by Malt - Dec-03-2019, 09:13 AM
RE: Need Help for my program - by sampathkumar - Dec-05-2019, 05:24 AM
RE: Need Help for my program - by Malt - Dec-06-2019, 12:16 PM
RE: Need Help for my program - by sampathkumar - Dec-07-2019, 08:24 AM
RE: Need Help for my program - by sampathkumar - Dec-24-2019, 05:08 AM
RE: Need Help for my program - by sampathkumar - Dec-25-2019, 06:31 AM
RE: Need Help for my program - by sampathkumar - Dec-27-2019, 06:16 AM
RE: Need Help for my program - by Malt - Dec-09-2019, 06:39 AM
RE: Need Help for my program - by HadoopHelp - Dec-09-2019, 09:31 AM
RE: Need Help for my program - by Malt - Dec-10-2019, 04:47 AM
RE: Need Help for my program - by sampathkumar - Dec-25-2019, 12:26 PM
RE: Need Help for my program - by Malt - Mar-27-2020, 06:45 PM
RE: Need Help for my program - by sampathkumar - Jul-07-2020, 02:21 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020