Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- import threading
- from py4j.java_gateway import JavaGateway
- import os.path
- from os import path
- import time
- import mailbox
- import shutil
- from glob import glob
- import sys
- from datetime import datetime
- sys.path.append(
- "C:\\Users\\etyur\\Documents\\ROBOTICS_AAU\\6_SEMESTER\\P_6")
- now = datetime.now()
- FILE_NAME = now.strftime("%d-%m-%Y-%H-%M")+"-scan"
- check_existent_file = "C:\\Users\\etyur\\Documents\\ROBOTICS_AAU\\6_SEMESTER\\P_6\\ConnectScannerJAVA\\ScanData1.txt"
- path_to_file_for_processing = "C:\\Users\\etyur\\Documents\\ROBOTICS_AAU\\6_SEMESTER\\P_6\\PointCloud_processing\\scans\\before\\unprocessed\\"+FILE_NAME+'.txt'
- path_to_folder_for_storing = "C:\\Users\\etyur\\Documents\\ROBOTICS_AAU\\6_SEMESTER\\P_6\\ConnectScannerJAVA\\Scans\\scan.txt"
- path_to_storing_folder_index = "C:\\Users\\etyur\\Documents\\ROBOTICS_AAU\\6_SEMESTER\\P_6\\ConnectScannerJAVA\\Scans\\scan"
- path_to_activate_point_cloud_processing = "C:\\Users\\etyur\\Documents\\ROBOTICS_AAU\\6_SEMESTER\\P_6\\PointCloud_processing\\program.py"
- def check_empty_directory():
- Flag = True
- while (1):
- #print("We are in the WHILE LOOP BEFORE IF")
- if (os.path.exists(check_existent_file)):
- # len(os.listdir("C:\\Users\\etyur\\Documents\\ROBOTICS_AAU\\6_SEMESTER\\P_6\\Empty_dir")) != 0:
- print("We are in the WHILE LOOP")
- print("Working directory contents the file for processing")
- time.sleep(5)
- shutil.copy(check_existent_file, path_to_file_for_processing)
- shutil.copy(check_existent_file, path_to_folder_for_storing)
- os.remove(check_existent_file)
- print("Temporary directory is empty")
- i = 0
- scanned_pointcloud = path_to_storing_folder_index + \
- str(i) + ".txt"
- while path.exists(scanned_pointcloud):
- scanned_pointcloud = path_to_storing_folder_index + \
- str(i) + ".txt"
- i += 1
- # do what you want to with that file...
- f = open(scanned_pointcloud, "w")
- # f.write(str(var))
- f.close()
- os.remove(path_to_folder_for_storing)
- if (os.path.exists(path_to_file_for_processing) and Flag==True):
- print("Directory for file processing contents the file for point_cloud_processing")
- os.system('python ' + path_to_activate_point_cloud_processing + " " + FILE_NAME)
- Flag=False
- time.sleep(1)
- # os.remove(path_to_file_for_processing)
- print("THE PROGRAM:PY STARTS NOW ")
- def fun1():
- path = os.getcwd()
- os.chdir("C:\\Users\\etyur\\Documents\\ROBOTICS_AAU\\6_SEMESTER\\P_6\\ConnectScannerJAVA")
- os.system("java ConnectScannerJNI")
- os.chdir("C:\\Users\\etyur\\Documents\\ROBOTICS_AAU\\6_SEMESTER\\P_6\\PointCloud_processing")
- print("Threat runs. Jump to file writer ... ")
- def threat_scanner_launch():
- testThread = threading.Thread(target=fun1)
- testThread.start()
- print("Run function to run threat!")
- if __name__ == "__main__":
- # main()
- threat_scanner_launch()
- check_empty_directory()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement