Ejemplo n.º 1
0
def edit_file(file_to_edit):
    '''Open file in a temp text page to allow editing'''
    
    cur_path = editor.get_path()
    #with open('tmp.txt', 'w') as file:
    try:
        file = open(TEMP_DIR+'/tmp.txt','w')
        file.write(file_to_edit.read())
        file.close()
        editor.reload_files()
        raw_input('*When you are finished editing the file, you must come back to console to confim changes*\n[Press Enter]')
        editor.open_file(TEMP)
        console.hide_output()
        while True:
            input = raw_input('Save Changes? Y,N: ')
            if input=='Y' or input=='y':
                editor.open_file(cur_path)
                return open(TEMP_DIR+'/tmp.txt','r')
            elif input=='N' or input=='n':
                editor.open_file(cur_path)
                return False

        
    except Exception, e:
        print e
        return False
Ejemplo n.º 2
0
def start_up():
	'''always receive mode'''
	def _start_up():
		while True:
			transfer.receive(wait_interval, False)
	console.hide_output()
	print 'Ready to receive.....'
	threading.Thread(target=_start_up, name='Transfer_Startup').start()
def handleCommandN(_self, _cmd):
	vc=UIApplication.sharedApplication().keyWindow().delegate()
	dvc=vc.detailViewController()
	console.hide_output()
	time.sleep(0.1)
	dvc.addTab_(dvc.addTabButtonItem())
	e=dvc.tabViewControllers()[-1]#newest added tab... maybe
	e.addNewFile_(e.addNewFileButton())
Ejemplo n.º 4
0
def show_file_chooser_panel(newTab=False):
    console.hide_output()
    if newTab:
        _addTab()
    time.sleep(0.1)
    @on_main_thread
    def showChooser():
        vc.showMasterWithAnimationDuration_(0.3)
    showChooser()
Ejemplo n.º 5
0
def main(args):
    p = argparse.ArgumentParser(description=__doc__)
    p.add_argument("file", action="store", help="file to open")
    ns = p.parse_args(args)
    
    editor.open_file(ns.file)
    console.hide_output()
    
    sys.exit(0)
Ejemplo n.º 6
0
 def __init__(self):
     console.hide_output()
     self.__make_self()
     self.__make_tvP()
     self.__make_bC()
     self.__make_biC()       
     self.did_load()
     self.layout()
     self.present('popover')
Ejemplo n.º 7
0
 def __init__(self, directory):
     console.hide_output()
     self.__make_self(directory)
     self.__make_lds()
     self.__make_tv()
     self.__make_biB()
     self.__make_biE()
     self.layout()
     self.did_load() 
     self.present('popover')
 def __init__(self):
     console.hide_output()
     self._make_self()
     self._do_warnings()
     self._make_wv()
     self._make_bi()
     self.did_load()
     self.layout()
     self.present('popover')
     ui.delay(self._start, 0.5)
     self.https.serve_forever()
def handleCommandS(_cmd,_sel):
	vc=UIApplication.sharedApplication().keyWindow().delegate()
	console.hide_output()
	time.sleep(0.1)
	@on_main_thread
	def showChooser():
		vc.showMasterWithAnimationDuration_(0.3)
	@on_main_thread
	def hideChooser():
		vc.hideMasterWithAnimationDuration_(0.3)
	if vc.masterVisible():
		hideChooser()
	else:
		showChooser()
Ejemplo n.º 10
0
def main(pyui_path, extra_func_mode=False, remove_title_bar=False, remove_status_bar=False):
	
	
	if not pyui_path:
		exit()
	if os.path.exists(pyui_path):
		a = GUI_Helper(pyui_path, extra_func_mode, remove_title_bar, remove_status_bar)
		to_path = os.path.dirname(pyui_path)+'/'+os.path.basename(pyui_path).replace('.pyui','')+'_GUI_Helper.py'
		#print a.text
		with open(to_path,'w') as f:
			f.write(a.text)
		editor.open_file(to_path, True)
		console.hide_output()
	else:
		console.hud_alert('pyui not found')
Ejemplo n.º 11
0
def main(self, line):
    args = bash(line)
    
    if len(args) == 1:
        if HAS_EDITOR:
            print 'Opening {0} in Pythonista editor.'.format(args[0])
            editor.open_file(os.path.join(os.getcwd(), args[0]))
            console.hide_output()
        else:
            import platform
            if platform.system() == 'Linux':
                os.system('vi {0}'.format(args[0]))
            else:
                print 'Unsupported platform'
    else:
        print 'Usage: editor <filename>'
Ejemplo n.º 12
0
Archivo: edit.py Proyecto: BBOOXX/stash
def open_temp(file='', new_tab=True):
    try:
        file_to_edit = file
        temp = tempfile.NamedTemporaryFile(dir=os.path.expanduser('~/Documents') , suffix='.py')
        cur_path = editor.get_path()
        if file_to_edit != '':
            try:
                to_edit = open(file_to_edit,'r')
            except:
                to_edit = open(file_to_edit,'w+')

            temp.write(to_edit.read())
            temp.flush()
            to_edit.close()
            
        print('***When you are finished editing the file, you must come back to console to confim changes***')
        editor.open_file(temp.name, new_tab)
        time.sleep(1.5)
        console.hide_output()
        input = raw_input('Save Changes? Y,N: ')
    
        if input=='Y' or input=='y':
            while True:
                try:
                    save_as = raw_input('Save file as [Enter to confirm]: %s' % file_to_edit) or file_to_edit
                except:
                    save_as = file_to_edit
                if save_as:
                    break

            if not new_tab:
                editor.open_file(cur_path) # restore previous script in editor
            with open(save_as,'w') as f:
                with open(temp.name,'r') as tmp:
                    f.write(tmp.read())
                    
            print('File Saved.')
        elif input=='N' or input=='n':
            if not new_tab:
                editor.open_file(cur_path) # restore previous script in editor
    
    except Exception as e:
        print(e)
        
    finally:
        temp.close()
Ejemplo n.º 13
0
Archivo: vdb.py Proyecto: jsbain/vdb
	def setup_ui(self):
		self.curframe = self.stack[self.curindex][0]
		# The f_locals dictionary is updated from the actual frame
		# locals whenever the .f_locals accessor is called, so we
		# cache it here to ensure that modifications are not overwritten.
		editor.clear_annotations()
		self.curframe_locals = self.curframe.f_locals
		frame=self.curframe
		
		editor.open_file(frame.f_code.co_filename)
		editor.annotate_line(frame.f_lineno,
									filename = frame.f_code.co_filename,
									scroll = True)
		self.show_menu()
		self.debugmenu['down'].enabled=self.curindex<len(self.stack)-1
		self.debugmenu['up'].enabled=self.curindex>0
		console.hide_output()
Ejemplo n.º 14
0
def main(self,file_to_edit):
    '''Open file in a temp text page to allow editing'''
    cur_path = editor.get_path()
    #with open('tmp.txt', 'w') as file:
    try:
        file = open(TEMP_DIR+'/tmp.txt','w')
        try:
            to_edit = open(file_to_edit,'r')
            
        except:
            to_edit = open(file_to_edit,'w+')
            
        file.write(to_edit.read())
        to_edit.close()
        file.close()
        editor.reload_files()
        raw_input('*When you are finished editing the file, you must come back to console to confim changes*\n[Press Enter]')
        editor.open_file(TEMP)
        console.hide_output()
        
        input = raw_input('Save Changes? Y,N: ')
            
        if input=='Y' or input=='y':
            save_as = raw_input('Save file as [Enter to confirm]: %s' % file_to_edit) or file_to_edit
            editor.open_file(cur_path)
            tmp = open(TEMP_DIR+'/tmp.txt','r')
            cur = open(save_as,'w')
            cur.write(tmp.read())
            cur.close()
            tmp.close()
                
        elif input=='N' or input=='n':
            editor.open_file(cur_path)


        
    except Exception, e:
        print e
        return False
Ejemplo n.º 15
0
def open_temp(file=''):
    try:
        file_to_edit = file
        temp = tempfile.NamedTemporaryFile(dir=os.path.expanduser('~/Documents') , suffix='.py')
        cur_path = editor.get_path()
        if file_to_edit != '':
            try:
                to_edit = open(file_to_edit,'r')
            except:
                to_edit = open(file_to_edit,'w+')

            temp.write(to_edit.read())
            temp.flush()
            to_edit.close()
            
        print '***When you are finished editing the file, you must come back to console to confim changes***'
        editor.open_file(temp.name)
        time.sleep(1.5)
        console.hide_output()
        input = raw_input('Save Changes? Y,N: ')
    
        if input=='Y' or input=='y':
            try:
                save_as = raw_input('Save file as [Enter to confirm]: %s' % file_to_edit) or file_to_edit
            except:
                save_as = file_to_edit
            
            editor.open_file(cur_path)
            with open(save_as,'w') as f:
                with open(temp.name,'r') as tmp:
                    f.write(tmp.read())
                    
            print 'File Saved.'
        elif input=='N' or input=='n':
            editor.open_file(cur_path)
    
    except Exception, e:
        print e
Ejemplo n.º 16
0
def _run_unit_tests(path):
    editor.clear_annotations()

    _remove_log_file()
    pytest.main([
        '-q', '-p', 'no:cacheprovider', '--junitxml={}'.format(_LOG_FILE_PATH),
        path
    ])
    attrib, annotations = _parse_log_file()

    _show_results(attrib, not annotations)

    scroll = True
    for a in annotations:
        editor.annotate_line(a.line,
                             a.text,
                             a.style.value,
                             True,
                             filename=a.filename,
                             scroll=scroll)
        scroll = False

    if _hide_console():
        console.hide_output()
Ejemplo n.º 17
0
 def will_close(self):
     if self.server is not None:
         self.server.shutdown()
     console.hide_output()
Ejemplo n.º 18
0
 def will_close(self):
     if self.server is not None:
         self.server.shutdown()
     console.hide_output()
Ejemplo n.º 19
0
 def close(self):
     self.root.close()
     console.hide_output()
Ejemplo n.º 20
0
def add_new_file():
    console.hide_output()
    time.sleep(0.1)
    _addTab()
    _addNewFile()
Ejemplo n.º 21
0
Archivo: edit.py Proyecto: BBOOXX/stash
def open_editor(file='', new_tab=True):
    if os.path.isfile(os.getcwd()+'/'+file):
        editor.open_file(os.getcwd()+'/'+file, new_tab)
        console.hide_output()
    else:
        editor.make_new_file(file if file else 'untitled.py') # new_tab not supported by make_new_file
Ejemplo n.º 22
0
def open_path(path):
    u"""Open the given file in the Pythonista editor, if possible
    """
    editor.open_file(path if NEW_EDITOR_MODULE else rel_to_docs(path))
    console.hide_output()
Ejemplo n.º 23
0
def newTab(_cmd,_sel):
	vc=UIApplication.sharedApplication().keyWindow().delegate()
	dvc=vc.detailViewController()
	console.hide_output()
	time.sleep(0.1)
	dvc.addTab_(dvc.addTabButtonItem())
Ejemplo n.º 24
0
def closeTab(_cmd,_sel):
	vc=UIApplication.sharedApplication().keyWindow().delegate()
	dvc=vc.detailViewController()
	console.hide_output()
	time.sleep(0.1)
	dvc.closeSelectedTab_(None)
Ejemplo n.º 25
0
 def will_close(self):
     self.__server.shutdown()
     console.hide_output()
Ejemplo n.º 26
0
def open_editor(file=''):
    if os.path.isfile(os.getcwd()+'/'+file):
        editor.open_file(os.getcwd()+'/'+file)
        console.hide_output()
    else:
        print 'File not found.'
Ejemplo n.º 27
0
 def openact(sender):
     full_file=os.path.join(self._repo_path(),str(self.list[section][row]))
     editor.open_file(full_file)
     console.hud_alert('open')
     console.hide_output()         
Ejemplo n.º 28
0
def open_path(path):
    u"""Open the given file in the Pythonista editor, if possible
    """
    editor.open_file(path if NEW_EDITOR_MODULE else rel_to_docs(path))
    console.hide_output()
Ejemplo n.º 29
0
def open_path(path):
    u"""Open the given file in the Pythonista editor, if possible
    """
    editor.open_file(rel_to_docs(path))
    console.hide_output()