mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-14 01:26:23 +01:00
use common function for launching an editor
This commit is contained in:
parent
a0aba626b3
commit
59b19bd012
@ -416,11 +416,8 @@ class Osc(cmdln.Cmdln):
|
||||
if not os.path.exists(project_dir + "/" + patchinfo):
|
||||
checkout_package(apiurl, project, patchinfo, prj_dir=project_dir)
|
||||
|
||||
if sys.platform[:3] != 'win':
|
||||
editor = os.getenv('EDITOR', default='vim')
|
||||
else:
|
||||
editor = os.getenv('EDITOR', default='notepad')
|
||||
subprocess.call('%s %s' % (editor, project_dir + "/" + patchinfo + "/_patchinfo"), shell=True)
|
||||
filename = project_dir + "/" + patchinfo + "/_patchinfo"
|
||||
run_editor(filename)
|
||||
|
||||
|
||||
@cmdln.option('-a', '--attribute', metavar='ATTRIBUTE',
|
||||
|
25
osc/core.py
25
osc/core.py
@ -1435,12 +1435,8 @@ rev: %s
|
||||
f.close()
|
||||
mtime_orig = os.stat(filename).st_mtime
|
||||
|
||||
if sys.platform[:3] != 'win':
|
||||
editor = os.getenv('EDITOR', default='vim')
|
||||
else:
|
||||
editor = os.getenv('EDITOR', default='notepad')
|
||||
while 1:
|
||||
subprocess.call('%s %s' % (editor, filename), shell=True)
|
||||
run_editor(filename)
|
||||
mtime = os.stat(filename).st_mtime
|
||||
if mtime_orig < mtime:
|
||||
filelist = open(filename).readlines()
|
||||
@ -2260,13 +2256,9 @@ class metafile:
|
||||
print 'Done.'
|
||||
|
||||
def edit(self):
|
||||
if sys.platform[:3] != 'win':
|
||||
editor = os.getenv('EDITOR', default='vim')
|
||||
else:
|
||||
editor = os.getenv('EDITOR', default='notepad')
|
||||
try:
|
||||
while 1:
|
||||
subprocess.call('%s %s' % (editor, self.filename), shell=True)
|
||||
run_editor(self.filename)
|
||||
try:
|
||||
self.sync()
|
||||
break
|
||||
@ -2488,6 +2480,13 @@ def read_meta_from_spec(specfile, *args):
|
||||
|
||||
return spec_data
|
||||
|
||||
def run_editor(filename):
|
||||
if sys.platform[:3] != 'win':
|
||||
editor = os.getenv('EDITOR', default='vim')
|
||||
else:
|
||||
editor = os.getenv('EDITOR', default='notepad')
|
||||
|
||||
return subprocess.call([ editor, filename ])
|
||||
|
||||
def edit_message(footer='', template=''):
|
||||
delim = '--This line, and those below, will be ignored--\n'
|
||||
@ -2502,13 +2501,9 @@ def edit_message(footer='', template=''):
|
||||
f.write(footer)
|
||||
f.close()
|
||||
|
||||
if sys.platform[:3] != 'win':
|
||||
editor = os.getenv('EDITOR', default='vim')
|
||||
else:
|
||||
editor = os.getenv('EDITOR', default='notepad')
|
||||
try:
|
||||
while 1:
|
||||
subprocess.call('%s %s' % (editor, filename), shell=True)
|
||||
run_editor(filename)
|
||||
msg = open(filename).read().split(delim)[0].rstrip()
|
||||
|
||||
if len(msg):
|
||||
|
Loading…
Reference in New Issue
Block a user