2012-05-04 11:40:30 +02:00
|
|
|
# coding: utf-8
|
|
|
|
#
|
|
|
|
# Copyright © 2012 Ejwa Software. All rights reserved.
|
|
|
|
#
|
|
|
|
# This file is part of gitinspector.
|
|
|
|
#
|
|
|
|
# gitinspector is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# gitinspector is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
def run(directory, command):
|
|
|
|
previous_directory = os.getcwd()
|
|
|
|
os.chdir(directory)
|
2012-05-04 15:15:41 +02:00
|
|
|
result = os.popen(command)
|
2012-05-04 11:40:30 +02:00
|
|
|
os.chdir(previous_directory)
|
|
|
|
|
2012-05-04 15:15:41 +02:00
|
|
|
return result
|
2012-05-14 15:23:15 +02:00
|
|
|
|
|
|
|
def open_file(directory, file_name):
|
|
|
|
previous_directory = os.getcwd()
|
|
|
|
os.chdir(directory)
|
|
|
|
file_r = open(file_name, "r")
|
|
|
|
os.chdir(previous_directory)
|
|
|
|
|
|
|
|
return file_r
|