Skip to content

Commit

Permalink
Merge branch 'single-tv' into dev
Browse files Browse the repository at this point in the history
Conflicts:
	bin/ssh.py
	stash.py
  • Loading branch information
ywangd committed Jan 25, 2015
2 parents 20f7b68 + 6cfb294 commit d076729
Show file tree
Hide file tree
Showing 4 changed files with 356 additions and 172 deletions.
19 changes: 10 additions & 9 deletions bin/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
--password PASSWORD Password for rsa/dsa key or password login
-p PORT, --port PORT port for ssh default: 22
'''
import os
import sys
import argparse
import threading
import time
Expand Down Expand Up @@ -96,6 +98,7 @@ def connect(self,host='', passwd=None, port=22):

def find_ssh_keys(self):
files = []
APP_DIR = os.environ['STASH_ROOT']
for file in os.listdir(APP_DIR+'/.ssh'):
if '.' not in file:
files.append(APP_DIR+'/.ssh/'+file)
Expand All @@ -122,10 +125,8 @@ def update_screen(self):
if str(item) != ' '*100:
break
count -=1
text = '\n'.join(self.screen.display[:count])
# clear the screen and write output
self.stash.term.seek(0)
self.stash.term.truncate()
text = '\n'.join(self.screen.display[:count]).rstrip() + ' '
self.stash.term.truncate(0, flush=False)
self.stash.term.write(text)

def single_exec(self,command):
Expand Down Expand Up @@ -170,14 +171,14 @@ def edit_file(self,remote_file):
import editor

try:
temp = tempfile.NamedTemporaryFile(dir=os.path.expanduser('~/Documents') , suffix='.py')
temp = tempfile.NamedTemporaryFile(dir=os.path.expanduser('~/Documents'), suffix='.py')
cur_path = editor.get_path()
sftp = self.ssh.open_sftp()
path = self.get_remote_path()
res = sftp.getfo(path+remote_file,temp)
#editor.open_file(temp.name)
temp.seek(0)
print '***When you are finished editing the file, you must come back to console to confim changes***'
print '***When you are finished editing the file, you must come back to console to confirm changes***'
editor.open_file(temp.name)
time.sleep(1.5)
console.hide_output()
Expand All @@ -187,7 +188,7 @@ def edit_file(self,remote_file):
with open(temp.name,'r') as f:
sftp.putfo(f,path+remote_file)
print 'File transfered.'
except exception, e:
except Exception, e:
print e
finally:
temp.close()
Expand All @@ -204,8 +205,8 @@ def interactive(self):
t1 = threading.Thread(target=self.stdout_thread)
t1.start()
while True:
if self.chan.send_ready():
tmp = sys.stdin.readline().replace('\n','')
if self.chan.send_ready():
tmp = raw_input()
ssh_args = tmp.split(' ')
if ssh_args[0] == 'exit':
self.exit()
Expand Down
23 changes: 20 additions & 3 deletions dummyui.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def in_background(func):
return func

def get_screen_size():
return (100, 100)
return 100, 100


class View(object):
Expand All @@ -26,6 +26,9 @@ def add_subview(self, v):
self.subviews.append(v)
v.superview = self

def remove_subview(self, v):
self.subviews.remove(v)

def present(self, style='popover'):
pass

Expand All @@ -41,8 +44,6 @@ def send_to_back(self):
def bring_to_front(self):
pass

def begin_editing(self):
pass

class TextField(View):
def __init__(self, *args, **kwargs):
Expand All @@ -53,6 +54,22 @@ class TextView(View):
def __init__(self, *args, **kwargs):
super(TextView, self).__init__(*args, **kwargs)
self.text = ''
self.selected_range = (0, 0)

def replace_range(self, rng, s):
self.text = self.text[:rng[0]] + s + self.text[rng[1]:]
tot_len = len(self.text)
self.selected_range = (tot_len, tot_len)

def begin_editing(self):
pass

def end_editing(self):
pass

class ScrollView(View):
pass


class Button(View):
def __init__(self, *args, **kwargs):
Expand Down
Loading

0 comments on commit d076729

Please sign in to comment.