コード例 #1
0
 def do_POST(self):
     form = cgi.FieldStorage(fp=self.rfile, headers=self.headers,
                             environ={'REQUEST_METHOD':'POST',
                            'CONTENT_TYPE':self.headers['Content-Type']})
     self.send_response(200)
     self.send_header('Content-Type', 'text/html')
     self.end_headers()
     field_item = form['file']
     uploaded_filename = None
     dest_filename = None
     file_data = field_item.file.read()
     uploaded_filename = field_item.filename     
     dest_filename = self.get_unused_filename(uploaded_filename)
     with open(dest_filename, 'w') as f:
         f.write(file_data)
     editor.reload_files()
     del file_data
     if uploaded_filename != dest_filename:
         message = '%s uploaded (renamed to %s).' % (uploaded_filename,
                                                    dest_filename)
     else:
         message = '%s uploaded.' % (uploaded_filename)
     '''--------end omz--------'''
     gcm.message = message
     gcm.file_name = dest_filename
     ui.delay(gcm.close, 0)
def main():
    if appex.is_running_extension():
        file_paths = appex.get_file_paths()
        assert len(file_paths) == 1, 'Invalid file paths: {}'.format(
            file_paths)
        srce_path = file_paths[0]
        if '/tmp/' in srce_path:
            dest_path = srce_path.split('/tmp/')[-1]
        else:
            dest_path = srce_path.split('/Repositories/')[-1]
        dest_path = os.path.join(from_wc, dest_path)
        file_path, file_name = os.path.split(dest_path)
        if not os.path.exists(file_path):
            os.makedirs(file_path)
        if os.path.isdir(srce_path):
            shutil.rmtree(dest_path, ignore_errors=True)
            print(shutil.copytree(srce_path, dest_path))
        else:
            print(shutil.copy2(srce_path, dest_path))
        print('{} was copied to {}'.format(file_name, file_path))
        editor.reload_files()  # refresh the editor to show the new file(s)
    else:
        print('''* In Working Copy app select a repo, file, or directory to be
copied into Pythonista.  Click the Share icon at the upperight.  Click Run
Pythonista Script.  Pick this script and click the run button.  When you return
to Pythonista the files should be in the 'from Working Copy'
directory.'''.replace('\n', ' ').replace('.  ', '.\n* '))
コード例 #3
0
 def do_POST(self):
     form = cgi.FieldStorage(fp=self.rfile,
                             headers=self.headers,
                             environ={
                                 'REQUEST_METHOD': 'POST',
                                 'CONTENT_TYPE':
                                 self.headers['Content-Type']
                             })
     self.send_response(200)
     self.send_header('Content-Type', 'text/html')
     self.end_headers()
     field_item = form['file']
     uploaded_filename = None
     dest_filename = None
     file_data = field_item.file.read()
     file_len = len(file_data)
     uploaded_filename = field_item.filename
     dest_filename = self.get_unused_filename(uploaded_filename)
     with open(dest_filename, 'w') as f:
         f.write(file_data)
     editor.reload_files()
     del file_data
     html = TEMPLATE
     if uploaded_filename != dest_filename:
         message = '%s uploaded (renamed to %s).' % (uploaded_filename,
                                                     dest_filename)
     else:
         message = '%s uploaded.' % (uploaded_filename)
コード例 #4
0
ファイル: FileTransfer.py プロジェクト: c0ns0le/Pythonista
	def do_POST(self):
		form = cgi.FieldStorage(fp=self.rfile, headers=self.headers,
		                        environ={'REQUEST_METHOD':'POST',
		                       'CONTENT_TYPE':self.headers['Content-Type']})
		self.send_response(200)
		self.send_header('Content-Type', 'text/html')
		self.end_headers()
		field_item = form['file']
		uploaded_filename = None
		dest_filename = None
		file_data = field_item.file.read()
		file_len = len(file_data)
		uploaded_filename = field_item.filename
		dest_filename = self.get_unused_filename(uploaded_filename)
		with open(dest_filename, 'w') as f:
			f.write(file_data)
		editor.reload_files()
		del file_data
		html = TEMPLATE
		if uploaded_filename != dest_filename:
			message = '%s uploaded (renamed to %s).' % (uploaded_filename,
			                                           dest_filename)
		else:
			message = '%s uploaded.' % (uploaded_filename)
		html = html.replace('{{ALERT}}',
		       '<div class="alert alert-success">%s</div>' % (message))
		html = html.replace('{{FILES}}', self.get_html_file_list())
		self.wfile.write(html)
コード例 #5
0
ファイル: edit.py プロジェクト: briarfox/shellista-ssh
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
コード例 #6
0
ファイル: apphack.py プロジェクト: wuxi20/Pythonista
 def run_script(sender):
     '''run a script without clearing glbals'''
     import editor
     editor.reload_files()
     exec(
         compile(open(editor.get_path()).read(), editor.get_path(), 'exec'),
         globals())
コード例 #7
0
 def do_POST(self):
     form = cgi.FieldStorage(
         fp=self.rfile,
         headers=self.headers,
         environ={"REQUEST_METHOD": "POST", "CONTENT_TYPE": self.headers["Content-Type"]},
     )
     self.send_response(200)
     self.send_header("Content-Type", "text/html")
     self.end_headers()
     field_item = form["file"]
     uploaded_filename = None
     dest_filename = None
     file_data = field_item.file.read()
     file_len = len(file_data)
     uploaded_filename = field_item.filename
     dest_filename = self.get_unused_filename(uploaded_filename)
     with open(dest_filename, "w") as f:
         f.write(file_data)
     editor.reload_files()
     del file_data
     html = TEMPLATE
     if uploaded_filename != dest_filename:
         message = "%s uploaded (renamed to %s)." % (uploaded_filename, dest_filename)
     else:
         message = "%s uploaded." % (uploaded_filename)
     html = html.replace("{{ALERT}}", '<div class="alert alert-success">%s</div>' % (message))
     html = html.replace("{{FILES}}", self.get_html_file_list())
     self.wfile.write(html)
コード例 #8
0
	def do_POST(self):
		form = cgi.FieldStorage(fp=self.rfile, headers=self.headers,
		environ={'REQUEST_METHOD':'POST',
		'CONTENT_TYPE':self.headers['Content-Type']})
		self.send_response(200)
		self.send_header('Content-Type', 'text/html')
		self.end_headers()
		field_item = form['file']
		uploaded_filename = None
		dest_filename = None
		file_data = field_item.file.read()
		file_len = len(file_data)
		uploaded_filename = field_item.filename
		dest_filename = self.get_unused_filename(uploaded_filename)
		with open(dest_filename, 'w') as f:
			f.write(file_data)
		editor.reload_files()
		del file_data
		html = TEMPLATE
		if uploaded_filename != dest_filename:
			message = '%s uploaded (renamed to %s).' % (uploaded_filename,
			dest_filename)
		else:
			message = '%s uploaded.' % (uploaded_filename)
		html = html.replace('{{ALERT}}',
		'<div class="alert alert-success">%s</div>' % (message))
		html = html.replace('{{FILES}}', self.get_html_file_list())
		self.wfile.write(html)
コード例 #9
0
 def tableview_did_select(self, tableview, section, row):
     # Called when the user selects a row
     if section == 0:
         if self.type == 0:
             # actions for folders
             if row == 0:
                 # Go Here in Shellista
                 nav.close()
                 print("Launching Shellista...")
                 try:
                     from Shellista import Shell
                 except ImportError as err:
                     print("Failed to import Shellista: " + err.message)
                     print("See note on Shellista integration at the top of filenav.py.")
                     print("> logout")
                     return
                 shell = Shell()
                 shell.prompt = '> '
                 shell.onecmd("cd " + self.path)
                 print("> cd " + self.path)
                 shell.cmdloop()
         elif self.type == 1:
             # actions for files
             if row == 0:
                 # Quick Look
                 nav.close()
                 time.sleep(1) # ui thread will hang otherwise
                 console.quicklook(self.path)
             elif row == 1:
                 # Open in Editor
                 open_path(self.path)
                 nav.close()
             elif row == 2:
                 # Copy & Open
                 destdir = full_path(os.path.join(SCRIPT_ROOT, "temp"))
                 if not os.path.exists(destdir):
                     os.mkdir(destdir)
                 destfile = full_path(os.path.join(destdir, os.path.basename(self.path).lstrip(".")))
                 shutil.copy(self.path, destfile)
                 editor.reload_files()
                 open_path(destfile)
                 nav.close()
             elif row == 3:
                 # Copy & Open as Text
                 destdir = full_path(os.path.join(SCRIPT_ROOT, "temp"))
                 if not os.path.exists(destdir):
                     os.mkdir(destdir)
                 destfile = full_path(os.path.join(destdir, os.path.basename(self.path).lstrip(".") + ".txt"))
                 shutil.copy(self.path, destfile)
                 editor.reload_files()
                 open_path(destfile)
                 nav.close()
             elif row == 4:
                 # Open In
                 if console.open_in(self.path):
                     nav.close()
                 else:
                     console.hud_alert("Failed to Open", "error")
コード例 #10
0
    def run_script(sender):
        '''run a script without clearing glbals'''
        import editor
        editor.reload_files()
        execfile(editor.get_path(), globals())

    #create_toolbar_button(run_script,'iow:play_32',0,'execfile')

    #remove_toolbar_button(0)
コード例 #11
0
 def tableview_did_select(self, tableview, section, row):
     u"""Called when the user selects a row.
     """
     key = self.lists[section][1][row][0]
     if key == "ios.quick_look":
         # Preview - Quick Look
         self.app.close()
         time.sleep(ANIM_DELAY)
         console.quicklook(self.fi.path)
     elif key == "editor.edit":
         # Open in Editor - editor
         open_path(self.fi.path)
         self.app.close()
     elif key == "editor.copy_edit":
         # Copy & Open - editor
         destdir = full_path(
             os.path.join(full_path(u"~"), u"Documents/temp"))
         if not os.path.exists(destdir):
             os.mkdir(destdir)
         destfile = full_path(
             os.path.join(destdir,
                          self.fi.basename().lstrip(u".")))
         shutil.copy(self.fi.path, destfile)
         editor.reload_files()
         open_path(destfile)
         self.app.close()
     elif key == "editor.copy_edit_txt":
         # Copy & Open as Text - editor
         destdir = full_path(
             os.path.join(full_path(u"~"), u"Documents/temp"))
         if not os.path.exists(destdir):
             os.mkdir(destdir)
         destfile = full_path(
             os.path.join(destdir,
                          self.fi.basename().lstrip(u".") + u".txt"))
         shutil.copy(self.fi.path, destfile)
         editor.reload_files()
         open_path(destfile)
         self.app.close()
     elif key == "console.print_image":
         # Show in Console - console
         console.show_image(self.fi.path)
     elif key == "sound.play_sound":
         # Play Sound - sound
         spath = rel_to_app(self.fi.path.rsplit(u".", 1)[0])
         sound.load_effect(spath)
         sound.play_effect(spath)
     elif key == "webbrowser.open":
         # Open Website - webbrowser
         webbrowser.open(u"file://" + self.fi.path)
         self.app.close()
     elif key == "ios.open_in":
         # Open In - External Apps
         if console.open_in(self.fi.path):
             self.app.close()
         else:
             console.hud_alert(u"Failed to Open", "error")
コード例 #12
0
	def run_script(sender):
		'''run a script without clearing glbals'''
		import editor
		editor.reload_files()
		execfile(editor.get_path(),globals())

	#create_toolbar_button(run_script,'iow:play_32',0,'execfile')
	
	#remove_toolbar_button(0)
コード例 #13
0
ファイル: WebIDE.py プロジェクト: Ivoah/WebIDE
def submit(): # This function will get called for each POST request to /
    filename = request.forms.get('filename') # Get the name of the file we are writing to
    fullname = os.path.realpath(os.path.join(ROOT, filename)) # Get the full path (relative to /, not ROOT this time)
    if fullname.startswith(ROOT): # If our file is in ROOT...
        with open(fullname, encoding = 'utf-8', mode = 'w') as f: # Then open the file...
            f.write(request.forms.get('code').replace('\r', '')) # And dump our code into it
        if PYTHONISTA: # And if we are in Pythonista
            editor.reload_files() # Then we need to reload the files so our newly edited file is visible
    else: # If it's not a valid file...
        return template('./main.tpl', files = make_file_tree(ROOT), error = 'Invalid filename') # Yell at the user some more
コード例 #14
0
ファイル: common.py プロジェクト: c0ns0le/Pythonista
 def tableview_did_select(self, tableview, section, row):
     u"""Called when the user selects a row.
     """
     key = self.lists[section][1][row][0]
     if key == "ios.quick_look":
         # Preview - Quick Look
         self.app.close()
         time.sleep(ANIM_DELAY)
         console.quicklook(self.fi.path)
     elif key == "editor.edit":
         # Open in Editor - editor
         open_path(self.fi.path)
         self.app.close()
     elif key == "editor.copy_edit":
         # Copy & Open - editor
         destdir = full_path(os.path.join(full_path(u"~"), u"Documents/temp"))
         if not os.path.exists(destdir):
             os.mkdir(destdir)
         destfile = full_path(os.path.join(destdir, self.fi.basename().lstrip(u".")))
         shutil.copy(self.fi.path, destfile)
         editor.reload_files()
         open_path(destfile)
         self.app.close()
     elif key == "editor.copy_edit_txt":
         # Copy & Open as Text - editor
         destdir = full_path(os.path.join(full_path(u"~"), u"Documents/temp"))
         if not os.path.exists(destdir):
             os.mkdir(destdir)
         destfile = full_path(os.path.join(destdir, self.fi.basename().lstrip(u".") + u".txt"))
         shutil.copy(self.fi.path, destfile)
         editor.reload_files()
         open_path(destfile)
         self.app.close()
     elif key == "console.print_image":
         # Show in Console - console
         console.show_image(self.fi.path)
     elif key == "sound.play_sound":
         # Play Sound - sound
         spath = rel_to_app(self.fi.path.rsplit(u".", 1)[0])
         sound.load_effect(spath)
         sound.play_effect(spath)
     elif key == "webbrowser.open":
         # Open Website - webbrowser
         webbrowser.open(u"file://" + self.fi.path)
         self.app.close()
     elif key == "ios.open_in":
         # Open In - External Apps
         if console.open_in(self.fi.path):
             self.app.close()
         else:
             console.hud_alert(u"Failed to Open", "error")
コード例 #15
0
	def do_POST(self):
		environ={'REQUEST_METHOD' : 'POST',
		'CONTENT_TYPE'   : self.headers['Content-Type']}
		form = cgi.FieldStorage(fp=self.rfile, headers=self.headers, environ=environ)
		self.do_headers()
		form_file = form['file']
		dest_filename = self.get_unused_filename(form_file.filename)
		with open(dest_filename, 'w') as outfile:
			outfile.write(form_file.file.read())
		editor.reload_files()
		samename = form_file.filename == dest_filename
		rename_msg = '' if samename else ' (renamed to {})'.format(dest_filename)
		print(('{} uploaded{}.'.format(form_file.filename, rename_msg)))
		'''--------end omz--------'''
		ui.delay(gCaptureMedia.close, 0)
		ui.delay(self.server.shutdown, 0)
コード例 #16
0
ファイル: CaptureMedia.py プロジェクト: c0ns0le/Pythonista
 def do_POST(self):
     environ={'REQUEST_METHOD' : 'POST',
              'CONTENT_TYPE'   : self.headers['Content-Type']}
     form = cgi.FieldStorage(fp=self.rfile, headers=self.headers, environ=environ)
     self.do_headers()
     form_file = form['file']
     dest_filename = self.get_unused_filename(form_file.filename)
     with open(dest_filename, 'w') as outfile:
         outfile.write(form_file.file.read())
     editor.reload_files()
     samename = form_file.filename == dest_filename
     rename_msg = '' if samename else ' (renamed to {})'.format(dest_filename)
     print('{} uploaded{}.'.format(form_file.filename, rename_msg))
     '''--------end omz--------'''
     ui.delay(gCaptureMedia.close, 0)
     ui.delay(self.server.shutdown, 0)
コード例 #17
0
def submit():  # This function will get called for each POST request to /
    filename = request.forms.get(
        'filename')  # Get the name of the file we are writing to
    fullname = os.path.realpath(os.path.join(
        ROOT,
        filename))  # Get the full path (relative to /, not ROOT this time)
    if fullname.startswith(ROOT):  # If our file is in ROOT...
        with open(fullname, encoding='utf-8',
                  mode='w') as f:  # Then open the file...
            f.write(request.forms.get('code').replace(
                '\r', ''))  # And dump our code into it
        if PYTHONISTA:  # And if we are in Pythonista
            editor.reload_files(
            )  # Then we need to reload the files so our newly edited file is visible
        print('Save file: %s' % filename)
        return '{"msg": "Save sucess."}'
    else:  # If it's not a valid file...
        return '{"msg": "Invalid file.Save Failure."}'
コード例 #18
0
def submit():  # This function will get called for each POST request to /
    filename = request.forms.get(
        'filename')  # Get the name of the file we are writing to
    fullname = os.path.realpath(os.path.join(
        ROOT,
        filename))  # Get the full path (relative to /, not ROOT this time)
    if fullname.startswith(ROOT):  # If our file is in ROOT...
        with open(fullname, encoding='utf-8',
                  mode='w') as f:  # Then open the file...
            f.write(request.forms.get('code').replace(
                '\r', ''))  # And dump our code into it
        if PYTHONISTA:  # And if we are in Pythonista
            editor.reload_files(
            )  # Then we need to reload the files so our newly edited file is visible
    else:  # If it's not a valid file...
        return template('./main.tpl',
                        files=make_file_tree(ROOT),
                        error='Invalid filename')  # Yell at the user some more
コード例 #19
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
コード例 #20
0
t.extractall()
t.close()
shutil.move('evernote-1.23.2/lib/evernote', 'evernote-sdk/evernote')
shutil.move('evernote-1.23.2/lib/thrift', 'evernote-sdk/thrift')
shutil.rmtree('evernote-1.23.2')

print 'Downloading httplib2...'
filename, headers = urllib.urlretrieve(
    'https://pypi.python.org/packages/source/h/httplib2/httplib2-0.7.7.tar.gz')
print 'Installing httplib2...'
t = tarfile.open(filename, 'r')
t.extractall()
t.close()
shutil.move('httplib2-0.7.7/python2/httplib2', 'evernote-sdk/httplib2')
shutil.rmtree('httplib2-0.7.7')

print 'Downloading oauth2...'
filename, headers = urllib.urlretrieve(
    'https://pypi.python.org/packages/source/o/oauth2/oauth2-1.5.211.tar.gz')
print 'Installing oauth2...'
t = tarfile.open(filename, 'r')
t.extractall()
t.close()
shutil.move('oauth2-1.5.211/oauth2', 'evernote-sdk/oauth2')
shutil.rmtree('oauth2-1.5.211')

import editor
editor.reload_files()

print 'Done.'
コード例 #21
0
ファイル: Download URL.py プロジェクト: c0ns0le/Pythonista
# https://gist.github.com/The-Penultimate-Defenestrator/f2a3a9e225d4c0ffb62f

import urllib2, appex, time, zipfile, os
a=time.time()
if appex.is_running_extension():
	url = appex.get_url()
	print url
	e=0
else:
	import clipboard, editor
	url = clipboard.get()
	e=1

response = urllib2.urlopen(url)
file = response.read()

name = url.split('/')[-1]
home = '/private/var/mobile/Containers/Shared/AppGroup/6FFE2397-8613-46A4-8F57-569169AA8746/Documents/'
output = open(home+name, 'w')
output.write(file)
output.close()

print 'Downloaded '+name+' to /Documents/'+name+' in '+str(time.time()-a)+' seconds'

if zipfile.is_zipfile(home+name):
	print 'Extracting zip...'
	zipfile.ZipFile(home+name).extractall(home)
	os.remove(home+name)
if e:
	editor.reload_files()
コード例 #22
0
def reload_pythonista_editor():
    print('Reloading Pythonista editor')
    import editor
    editor.reload_files()
コード例 #23
0
ファイル: filenav.py プロジェクト: Phuket2/pythonista-scripts
 def tableview_did_select(self, tableview, section, row):
     # Called when the user selects a row
     key = self.lists[section][1][row][0]
     if key == "shellista-cd":
         # Go Here - Shellista
         nav.close()
         print("Launching Shellista...")
         try:
             from Shellista import Shell
         except ImportError as err:
             print("Failed to import Shellista: " + err.message)
             print("See note on Shellista integration at the top of filenav.py.")
             print("> logout")
             return
         shell = Shell()
         shell.prompt = "> "
         shell.onecmd("cd " + self.fi.path)
         print("> cd " + self.fi.path)
         shell.cmdloop()
     elif key == "ios-qlook":
         # Preview - Quick Look
         nav.close()
         time.sleep(1)  # ui thread will hang otherwise
         console.quicklook(self.fi.path)
     elif key == "pysta-edit":
         # Open in Editor - Pythonista
         open_path(self.fi.path)
         nav.close()
     elif key == "pysta-cpedit":
         # Copy & Open - Pythonista
         destdir = full_path(os.path.join(SCRIPT_ROOT, "temp"))
         if not os.path.exists(destdir):
             os.mkdir(destdir)
         destfile = full_path(os.path.join(destdir, self.fi.basename().lstrip(".")))
         shutil.copy(self.fi.path, destfile)
         editor.reload_files()
         open_path(destfile)
         nav.close()
     elif key == "pysta-cptxt":
         # Copy & Open as Text - Pythonista
         destdir = full_path(os.path.join(SCRIPT_ROOT, "temp"))
         if not os.path.exists(destdir):
             os.mkdir(destdir)
         destfile = full_path(os.path.join(destdir, self.fi.basename().lstrip(".") + ".txt"))
         shutil.copy(self.fi.path, destfile)
         editor.reload_files()
         open_path(destfile)
         nav.close()
     elif key == "console-printimg":
         # Show in Console - console
         console.show_image(self.fi.path)
     elif key == "sound-playsound":
         # Play Sound - sound
         spath = rel_to_app(self.fi.path.rsplit(".", 1)[0])
         sound.load_effect(spath)
         sound.play_effect(spath)
     elif key == "webbrowser-open":
         # Open Website - webbrowser
         webbrowser.open("file://" + self.fi.path)
         nav.close()
     elif key == "ios-openin":
         # Open In - External Apps
         if console.open_in(self.fi.path):
             nav.close()
         else:
             console.hud_alert("Failed to Open", "error")
コード例 #24
0
ファイル: filenav.py プロジェクト: cclauss/Pythonista-4
 def tableview_did_select(self, tableview, section, row):
     # Called when the user selects a row
     key = self.lists[section][1][row][0]
     if key == "shellista-cd":
         # Go Here - Shellista
         nav.close()
         print("Launching Shellista...")
         try:
             from Shellista import Shell
         except ImportError as err:
             print("Failed to import Shellista: " + err.message)
             print("See note on Shellista integration at the top of filenav.py.")
             print("> logout")
             return
         shell = Shell()
         shell.prompt = '> '
         shell.onecmd("cd " + self.fi.path)
         print("> cd " + self.fi.path)
         shell.cmdloop()
     elif key == "ios-qlook":
         # Preview - Quick Look
         nav.close()
         time.sleep(1) # ui thread will hang otherwise
         console.quicklook(self.fi.path)
     elif key == "pysta-edit":
         # Open in Editor - Pythonista
         open_path(self.fi.path)
         nav.close()
     elif key == "pysta-cpedit":
         # Copy & Open - Pythonista
         destdir = full_path(os.path.join(SCRIPT_ROOT, "temp"))
         if not os.path.exists(destdir):
             os.mkdir(destdir)
         destfile = full_path(os.path.join(destdir, self.fi.basename().lstrip(".")))
         shutil.copy(self.fi.path, destfile)
         editor.reload_files()
         open_path(destfile)
         nav.close()
     elif key == "pysta-cptxt":
         # Copy & Open as Text - Pythonista
         destdir = full_path(os.path.join(SCRIPT_ROOT, "temp"))
         if not os.path.exists(destdir):
             os.mkdir(destdir)
         destfile = full_path(os.path.join(destdir, self.fi.basename().lstrip(".") + ".txt"))
         shutil.copy(self.fi.path, destfile)
         editor.reload_files()
         open_path(destfile)
         nav.close()
     elif key == "console-printimg":
         # Show in Console - console
         console.show_image(self.fi.path)
     elif key == "sound-playsound":
         # Play Sound - sound
         spath = rel_to_app(self.fi.path.rsplit(".", 1)[0])
         sound.load_effect(spath)
         sound.play_effect(spath)
     elif key == "webbrowser-open":
         # Open Website - webbrowser
         webbrowser.open("file://" + self.fi.path)
         nav.close()
     elif key == "ios-openin":
         # Open In - External Apps
         if console.open_in(self.fi.path):
             nav.close()
         else:
             console.hud_alert("Failed to Open", "error")
コード例 #25
0
ファイル: WebIDE.py プロジェクト: cclauss/WebIDE
def submit():
    with open(os.path.join(ROOT, request.forms.get('filename')), 'w') as f:
        f.write(request.forms.get('code').replace('\r', ''))
        if PYTHONISTA: editor.reload_files()
コード例 #26
0
	def run_script(sender):
		'''run a script without clearing glbals'''
		import editor
		editor.reload_files()
		execfile(editor.get_path(),globals())
コード例 #27
0
ファイル: WebIDE.py プロジェクト: ywangd/WebIDE
def submit():
    filename = os.path.join(ROOT, request.forms.get('filename'))
    with open(filename, 'w') as f:
        f.write(request.forms.get('code').replace('\r', ''))
    if PYTHONISTA:
        editor.reload_files()
コード例 #28
0
def reload_pythonista_editor():
    print('Reloading Pythonista editor')
    import editor
    editor.reload_files()