Пример #1
0
def gui(conflictFile, diff): # for safety from file and diff mismatch, this fn should never be called explicitly# if len(diff) is 0:	print("diff data structure not found");	elif cFhandel.count(RSC) not len(diff):	print("data structure mismatch")
	gui = os.tempDir + os.path.basename(conflictFile) + "resolve.html"
	#	ensure all None in diff dict get replaced by empty strings
	src, dest = openFile(conflictFile), openFile(gui, "wt")
	dest.write(initString % os.path.basename(coflictFile))
	
	writeBuffer = str()
	for i, char in enumerate(src):
		if char is RSC:
			dest.write(writeBuffer);	writeBuffer = ""
			try:
				ds = diff[i]
			except KeyError:
				dest.write(ERROR)
				break	#raise
			if ds[0] is None:
				dest.write(inserter % (i, ds[1]))
			elif ds[1] is None:
				dest.write(deleter % (i, ds[0]))
			else:
				dest.write(deleter % (i, ds[0]))
				dest.write(inserter % (i, ds[1]))
		else:
			writeBuffer+= char
	
	dest.write(endString)
	closeFiles(src, dest)
	os.start(gui) # js can not write the final result to disk, hence wait ?threading? till file is closed
	return
Пример #2
0
    def __startTerminalManager(self):
        try:
            if self.settings_window.get_tm_path() and self.settings_window.get_tm_path().strip():
                if not self.__processExists('TerminalManager'):
                    # Get TMR current path
                    tmr_dir = os.path.dirname(
                        os.path.realpath(getCurrentPath()))

                    # Let TMR load, then start Terminal Manager
                    time.sleep(0.3)
                    os.chdir(self.settings_window.get_tm_path().split(
                        'TerminalManager.exe')[0])
                    os.start(self.settings_window.get_tm_path())
                    time.sleep(0.1)
                    os.chdir(tmr_dir)
        except BaseException:
            pass
Пример #3
0
def button_click_function():
    names = name.get()
    surnames = surname.get()
    emails = email.get()
    genders = male_female.get()
    user_teacher_student = user_type.get()
    if condition_var.get() == 0:
        checked = "Please check the checkbox"
    else:
        checked = "you have succesfully checked the check box button"

    #print(f"your name is {names} \n your surname is {surnames} \n your email is {emails}")        
    #print(f"your gender is {genders} \n your usertype is {user_teacher_student}")        

    all_details = (f"your name is {names} \n your surname is {surnames} \n your email is {emails} \n your gender is {genders} \n your usertype is {user_teacher_student}")
    new_label_of_all_detail = ttk.Label(window,text = all_details)
    new_label_of_all_detail.grid(row = 7,column = 0)
    
    with open("zzzz.txt" , "a") as file:
        file.write(f"{names},{surnames},{emails},{genders},{user_teacher_student},{checked}")
    
    with open("vvvzz.csv","a",newlines="") as file:
        new_data = DictWriter(file,fieldnames = ["useranme","surname","email","Gender","type","checkbox"])
        if os.start("vvvzz.csv").st_size == 0:
            new_data.writeheader()
        new_data.writerow({
            "useranme":names,
            "surname":surnames,
            "email":emails,
            "Gender":genders,
            "type":user_teacher_student,
            "checkbox":checked,
        })
    name_entry_box.delete(0,tk.END)
    surname_entry_box.delete(0,tk.END)
    email_entry_box.delete(0,tk.END)
Пример #4
0
def main():
    os = OperatingSystem()
    os.start()
    os.create_file('foo', 'hello', '-rw-r-r')
    os.create_process('bar', 'ls /tmp', 'ls -al')
Пример #5
0
def file_size(fname):
    import os
    startinfo=os.start(fname)
    return startinfo.st_size
Пример #6
0
Lines = file1.readlines() 
count = 0
for line in Lines: 
    print("Line{}: {}".format(count, line.strip()))

O/p:Line0: Geeks
Line0: for
Line0: Geeks


#file=open("gfg.txt","r")
count=0
content=file.read()
colist=content.split("\n")
for i in colist:
        if i:
            counter+=1
print("this is number of lines in the file")
print(count)

#def file_size(fname):
    import os
    startinfo=os.start(fname)
    return startinfo.st_size
print("file size in bytes of a plain file:", file_size("test.txt"))


#with open("hello.txt")as f:
with open("copy.txt","w") as f1:
    for line in f:
        f1.write(line)
Пример #7
0
     query=query.replace("wikipedia", "")
     results=wikipedia.summary(query,sentences=2)
     speak("According To Wikipedia.")
     prine(results)
     speak(results)
 elif "open youtube" in query:
     webbrowser.open("youtube.com")
 elif "open google" in query:
     webbrowser.open("google.com")
 elif "open stackoverflow" in query:
     webbrowser.open("stackoverflow.com")
 elif "play music" in query:
     music_dir="Music"
     songs=os.listdir(music_dir)
     print(songs)
     os.start(os.path.join(music_dir,songs[0]))
 elif "play online music" in query:
     webbrowser.open("gaana.com")
 elif "the time" in query:
     strTime=datetime.datetime.now().strftime("%H:%M:%S")
     speak(f"The current time is {strTime}.")
 elif "open code" in query:
     codePath=r"Address where your code editor is installed"
     os.startfile(codePath)
 elif "who are you" in query:
     speak("I am JARVIS. Initially i was used in avengers seris.")
 elif "email to" in query:
     try:
         speak(r"What's the email.")
         content=takeCommand()
         to="Email"
>>> os.getcwd()
'/Users/anmolrajarora/Documents/aws'
>>> os.listdir()
['05-IAM_roles.mov', '.DS_Store', '01-CloudComputingIntro.mov', 'aws-cdn.mov', '05-IAM.mov']
>>> songs = os.listdir()
>>> songs
['05-IAM_roles.mov', '.DS_Store', '01-CloudComputingIntro.mov', 'aws-cdn.mov', '05-IAM.mov']
>>> songs.pop(1)
'.DS_Store'
>>> songs
['05-IAM_roles.mov', '01-CloudComputingIntro.mov', 'aws-cdn.mov', '05-IAM.mov']
>>> import random
>>> song = random.choice(songs)
>>> song
'01-CloudComputingIntro.mov'
>>> os.start(song)
Traceback (most recent call last):
  File "<pyshell#39>", line 1, in <module>
    os.start(song)
AttributeError: module 'os' has no attribute 'start'
>>> os.startfile(song)
Traceback (most recent call last):
  File "<pyshell#40>", line 1, in <module>
    os.startfile(song)
AttributeError: module 'os' has no attribute 'startfile'
>>> import subprocess
>>> subprocess.call(['open', song])
0
>>> subprocess.call(['open', 'Applications/TextEdit'])
1
>>> subprocess.call(['open', '/Applications/TextEdit'])
Пример #9
0
    sys.exit(0)

out_file = open(r'Z:\before.csv', 'wb')
p = Popen([r'Y:\tools\ss\autorunsc.exe', '-a', '-c', '--accepteula'],
          STDOUT=out_file)
p.wait()
out_file.close()

procmon = Popen([
    r'Y:\tools\ss\procmon.exe', '/BackingFile', '/NoFilter', r'Z:\capture.pml'
])
capturebat = Popen([
    r'C:\Program Files\Capture\CaptureBAT.exe', '-c', '-l', r'Z:\capture.log'
])

os.start(r'Z:\target.exe')

time.sleep(1)

call([r'Y:\tools\ss\procmon.exe', '/Terminate'])
call([r'Y:\tools\ss\pskill.exe', '-accepteula', 'CaptureBAT.exe'])

call([
    r'Y:\tools\ss\procmon.exe', '/OpenLog', r'Z:\capture.pml', '/SaveAs',
    r'Z:\capture.csv'
])

out_file = open(r'Z:\after.csv', 'wb')
p = Popen([r'Y:\tools\ss\autorunsc.exe', '-a', '-c', '--accepteula'],
          STDOUT=out_file)
p.wait()
Пример #10
0
def execute_program(program, params, output):
	Popen(params, stdout=output)

# check to see if we are in auto mode
if not os.path.exists(r'Z:\auto'):
	sys.exit(0)

out_file = open(r'Z:\before.csv', 'wb')
call([r'Y:\tools\ss\autorunsc.exe', '-a', '-c', '--accepteula'], STDOUT=out_file)
out_file.close()

procmon = Popen([r'Y:\tools\ss\procmon.exe', '/BackingFile', '/NoFilter', r'Z:\capture.pml'])
capturebat = Popen([r'C:\Program Files\Capture\CaptureBAT.exe', '-c', '-l', r'Z:\capture.log'])

os.start(r'Z:\target.exe')

time.sleep(1)

call([r'Y:\tools\ss\procmon.exe', '/Terminate'])
call([r'Y:\tools\ss\pskill.exe', '-accepteula', 'CaptureBAT.exe'])

call([r'Y:\tools\ss\procmon.exe', '/OpenLog', r'Z:\capture.pml', '/SaveAs', r'Z:\capture.csv'])

out_file = open(r'Z:\after.csv', 'wb')
call([r'Y:\tools\ss\autorunsc.exe', '-a', '-c', '--accepteula'], STDOUT=out_file)
out_file.close()

#call([r'C:\Program Files\MANDIANT\Memoryze\MemoryDD.bat' '-o' r'Z:\\'])

open(r'Z:\done', 'wb')