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