Merge lp:~tony-badwolf/quickly/editors into lp:quickly

Proposed by Tony Byrne on 2011-11-06
Status: Rejected
Rejected by: Didier Roche on 2019-02-12
Proposed branch: lp:~tony-badwolf/quickly/editors
Merge into: lp:quickly
Diff against target: 192 lines (+64/-54)
5 files modified
data/templates/ubuntu-application/configure.py (+2/-2)
data/templates/ubuntu-application/edit.py (+1/-1)
data/templates/ubuntu-application/internal/quicklyutils.py (+0/-39)
data/templates/ubuntu-flash-game/internal/quicklyutils.py (+0/-12)
quickly/templatetools.py (+61/-0)
To merge this branch: bzr merge lp:~tony-badwolf/quickly/editors
Reviewer Review Type Date Requested Status
Didier Roche 2011-11-06 Needs Information on 2011-12-02
Review via email: mp+81383@code.launchpad.net
To post a comment you must log in.
Didier Roche (didrocks) wrote :

Looks mostly good as well, thanks for your work there as well :)

Just a question on:

179 + editor = get_editor()
in read_input()

The idea was that quickly configure will still run gedit to have an easy editor for configuring that as well, and not nano or vim. Can't we call there get_quickly_editor() as it was before?

review: Needs Information
Didier Roche (didrocks) wrote :

Didn't get any information. Rejecting due to the age of the MP.

Unmerged revisions

639. By Tony Byrne <email address hidden> <email address hidden> on 2011-11-06

allows different editors for editing project and configuring dependencies
fixes bug 862302 by informative message instead of crashing

use case
export EDITOR=nano
export QUICKLY_EDITOR=geany
quickly edit &
quickly configure dependencies

removed another bug
read_input() piped stdout which broke subprocess.call(['nano'])

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/templates/ubuntu-application/configure.py'
2--- data/templates/ubuntu-application/configure.py 2010-10-18 18:39:04 +0000
3+++ data/templates/ubuntu-application/configure.py 2011-11-06 02:17:24 +0000
4@@ -82,7 +82,7 @@
5 if len(argv) > 2:
6 project_name = argv[2]
7 else:
8- project_name = quicklyutils.read_input()
9+ project_name = templatetools.read_input()
10 # need to try and get the original project name if it exists. We'll need this
11 # to replace any existing settings
12 if not configurationhandler.project_config:
13@@ -158,7 +158,7 @@
14 dependencies = [elem.strip() for elem in configurationhandler.project_config['dependencies'].split(',') if elem]
15 except KeyError:
16 dependencies = []
17- userinput = quicklyutils.read_input('\n'.join(dependencies))
18+ userinput = templatetools.read_input('\n'.join(dependencies))
19 dependencies = []
20 for depends in userinput.split('\n'):
21 dependencies.extend([elem.strip() for elem in depends.split(',') if elem])
22
23=== modified file 'data/templates/ubuntu-application/edit.py'
24--- data/templates/ubuntu-application/edit.py 2011-04-27 15:02:41 +0000
25+++ data/templates/ubuntu-application/edit.py 2011-11-06 02:17:24 +0000
26@@ -65,7 +65,7 @@
27 # add helpfile sources
28 filelist.extend(glob.glob('help/C/*.page'))
29
30-editor = quicklyutils.get_quickly_editors()
31+editor = templatetools.get_quickly_editors()
32 if templatetools.in_verbose_mode():
33 instance = subprocess.Popen([editor] + filelist)
34 else:
35
36=== modified file 'data/templates/ubuntu-application/internal/quicklyutils.py'
37--- data/templates/ubuntu-application/internal/quicklyutils.py 2011-07-22 10:47:34 +0000
38+++ data/templates/ubuntu-application/internal/quicklyutils.py 2011-11-06 02:17:24 +0000
39@@ -19,7 +19,6 @@
40 import re
41 import sys
42 import subprocess
43-import tempfile
44 from xml.etree import ElementTree as etree
45
46 import gettext
47@@ -200,44 +199,6 @@
48 buffered_message +=' %s' % line
49 return(changelog)
50
51-
52-def get_quickly_editors():
53- '''Return prefered editor for ubuntu-application template'''
54-
55- default_editor = os.environ.get("QUICKLY_EDITOR")
56- if not default_editor:
57- default_editor = os.environ.get("EDITOR")
58- if not default_editor:
59- default_editor = os.environ.get("SELECTED_EDITOR")
60- if default_editor:
61- editor = default_editor
62- elif templatetools.is_X_display():
63- editor = "gedit"
64- else:
65- editor = "nano"
66- return editor
67-
68-def read_input(start=''):
69- depfile_name = tempfile.mkstemp()[1]
70- open(depfile_name,'w').write(start)
71-
72- # Run the editor with a new tmpdir. This is because gedit uses tmpdir
73- # to find other instances of gedit, and we don't want that. If we allowed
74- # that, gedit would return immediately and open a new tab in the other
75- # gedit. This makes it difficult to tell when user is done editing (how
76- # to detect that vs nano opening and closing without the user saving it?).
77- editor = get_quickly_editors()
78- subenv = dict(os.environ)
79- subenv['TMPDIR'] = tempfile.mkdtemp()
80- subprocess.call([editor, depfile_name], stdout=subprocess.PIPE, env=subenv)
81- os.rmdir(subenv['TMPDIR'])
82-
83- # Grab file contents
84- rv = file(depfile_name, 'r').read().strip()
85- os.remove(depfile_name)
86-
87- return rv
88-
89 def take_email_from_string(value):
90 '''Try to take an email from a string'''
91
92
93=== modified file 'data/templates/ubuntu-flash-game/internal/quicklyutils.py'
94--- data/templates/ubuntu-flash-game/internal/quicklyutils.py 2011-07-22 10:47:34 +0000
95+++ data/templates/ubuntu-flash-game/internal/quicklyutils.py 2011-11-06 02:17:24 +0000
96@@ -178,18 +178,6 @@
97 return(changelog)
98
99
100-def get_quickly_editors():
101- '''Return prefered editor for ubuntu-application template'''
102-
103- editor = "gedit"
104- default_editor = os.environ.get("EDITOR")
105- if not default_editor:
106- default_editor = os.environ.get("SELECTED_EDITOR")
107- if default_editor:
108- editor = default_editor
109- return editor
110-
111-
112 def take_email_from_string(value):
113 '''Try to take an email from a string'''
114
115
116=== modified file 'quickly/templatetools.py'
117--- quickly/templatetools.py 2011-06-06 10:14:40 +0000
118+++ quickly/templatetools.py 2011-11-06 02:17:24 +0000
119@@ -20,6 +20,8 @@
120 import string
121 import sys
122 import re
123+import tempfile
124+import subprocess
125
126 import gettext
127 from gettext import gettext as _
128@@ -37,6 +39,65 @@
129 def __str__(self):
130 return self.msg
131
132+def get_editor():
133+ '''Return prefered editor for quickly
134+
135+ edit and wait, for instance quickly configure dependencies'''
136+
137+ default_editor = os.environ.get("EDITOR")
138+ if not default_editor:
139+ default_editor = os.environ.get("SELECTED_EDITOR")
140+ if default_editor:
141+ editor = default_editor
142+ elif templatetools.is_X_display():
143+ editor = "gedit"
144+ else:
145+ editor = "nano"
146+
147+ editor_test = subprocess.call(['/usr/bin/which', editor])
148+ if editor_test:
149+ print 'cannot start preferred editor: %s' % editor
150+ print 'install %s, or change environment to use another editor' % editor
151+ sys.exit(4)
152+ return editor
153+
154+def get_quickly_editors():
155+ '''Return prefered ide for templates
156+
157+ add files to ide even if already running'''
158+
159+ default_editor = os.environ.get("QUICKLY_EDITOR")
160+ if not default_editor:
161+ default_editor = get_editor()
162+
163+ editor_test = subprocess.call(['/usr/bin/which', default_editor])
164+ if editor_test:
165+ print 'cannot start preferred editor: %s' % default_editor
166+ print 'install %s, or change environment to use another editor' % default_editor
167+ sys.exit(4)
168+ return default_editor
169+
170+def read_input(start=''):
171+ depfile_name = tempfile.mkstemp()[1]
172+ open(depfile_name,'w').write(start)
173+
174+ # Run the editor with a new tmpdir. This is because gedit uses tmpdir
175+ # to find other instances of gedit, and we don't want that. If we allowed
176+ # that, gedit would return immediately and open a new tab in the other
177+ # gedit. This makes it difficult to tell when user is done editing (how
178+ # to detect that vs nano opening and closing without the user saving it?).
179+ editor = get_editor()
180+ subenv = dict(os.environ)
181+ subenv['TMPDIR'] = tempfile.mkdtemp()
182+ subprocess.call([editor, depfile_name], env=subenv)
183+ os.rmdir(subenv['TMPDIR'])
184+
185+ # Grab file contents
186+ rv = file(depfile_name, 'r').read().strip()
187+ os.remove(depfile_name)
188+
189+ return rv
190+
191 def handle_additional_parameters(args, help=None, shell_completion=None, usage=None):
192 """Enable handling additional parameter like help or shell_completion"""
193

Subscribers

People subscribed via source and target branches