ActionsAPI refactor, exception handling, use internal functions against external ones and etc.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
ReFactor ActionsAPI:
|
||||
|
||||
pisitools.py - %80
|
||||
pisitools.py - %90
|
||||
autotools.py - %100
|
||||
get.py - %75
|
||||
kde.py - %0
|
||||
libtools.py - %75
|
||||
kde.py - %75
|
||||
libtools.py - %90
|
||||
pisitoolsfunctions.py - %75
|
||||
shelltools.py - %50
|
||||
shelltools.py - %75
|
||||
variables.py - %100
|
||||
coreutils.py - %100
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
# any later version.
|
||||
#
|
||||
# Please read the COPYING file.
|
||||
#
|
||||
|
||||
# Standard Python Modules
|
||||
import os
|
||||
@@ -47,24 +46,30 @@ def configure(parameters = ''):
|
||||
if can_access_file('configure'):
|
||||
gnuconfig_update()
|
||||
|
||||
configure_string = './configure --prefix=/%s --host=%s --mandir=/%s \
|
||||
--infodir=/%s --datadir=/%s --sysconfdir=/%s \
|
||||
--localstatedir=/%s %s' \
|
||||
% (get.defaultprefixDIR(), get.HOST(), get.manDIR(),
|
||||
get.infoDIR(), get.dataDIR(), get.confDIR(),
|
||||
get.localstateDIR(), parameters)
|
||||
args = './configure \
|
||||
--prefix=/%s \
|
||||
--host=%s \
|
||||
--mandir=/%s \
|
||||
--infodir=/%s \
|
||||
--datadir=/%s \
|
||||
--sysconfdir=/%s \
|
||||
--localstatedir=/%s \
|
||||
%s' % (get.defaultprefixDIR(), \
|
||||
get.HOST(), get.manDIR(), \
|
||||
get.infoDIR(), get.dataDIR(), \
|
||||
get.confDIR(), get.localstateDIR(), parameters)
|
||||
|
||||
if system(configure_string):
|
||||
if system(args):
|
||||
raise ConfigureError('!!! Configure failed...\n')
|
||||
else:
|
||||
raise ConfigureError('!!! No configure script found...\n')
|
||||
|
||||
def rawConfigure(parameters = '', prefix=''):
|
||||
def rawConfigure(parameters = ''):
|
||||
'''configure source with given parameters = "--prefix=/usr --libdir=/usr/lib --with-nls"'''
|
||||
if can_access_file('configure'):
|
||||
gnuconfig_update()
|
||||
|
||||
if system('%s ./configure %s' % (prefix, parameters)):
|
||||
if system('./configure %s' % parameters):
|
||||
raise ConfigureError('!!! Configure failed...\n')
|
||||
else:
|
||||
raise ConfigureError('!!! No configure script found...\n')
|
||||
@@ -81,7 +86,7 @@ def make(parameters = ''):
|
||||
def install(parameters = ''):
|
||||
'''install source into install directory with given parameters'''
|
||||
if can_access_file('makefile') or can_access_file('Makefile') or can_access_file('GNUmakefile'):
|
||||
install_string = 'make prefix=%(prefix)s/%(defaultprefix)s \
|
||||
args = 'make prefix=%(prefix)s/%(defaultprefix)s \
|
||||
datadir=%(prefix)s/%(data)s \
|
||||
infodir=%(prefix)s/%(info)s \
|
||||
localstatedir=%(prefix)s/%(localstate)s \
|
||||
@@ -97,7 +102,7 @@ def install(parameters = ''):
|
||||
'data': get.dataDIR(),
|
||||
'parameters': parameters}
|
||||
|
||||
if system(install_string):
|
||||
if system(args):
|
||||
raise InstallError('!!! Install failed...\n')
|
||||
else:
|
||||
raise InstallError('!!! No Makefile found...\n')
|
||||
@@ -113,14 +118,14 @@ def rawInstall(parameters = ''):
|
||||
def aclocal(parameters = ''):
|
||||
'''generates an aclocal.m4 based on the contents of configure.in.'''
|
||||
if system('aclocal %s' % parameters):
|
||||
raise RunTimeError("!!!! Running aclocal failed...")
|
||||
raise RunTimeError('!!! Running aclocal failed...')
|
||||
|
||||
def autoconf(parameters = ''):
|
||||
'''generates a configure script'''
|
||||
if system('autoconf %s' % parameters):
|
||||
raise RunTimeError("!!!! Running autoconf failed...")
|
||||
raise RunTimeError('!!! Running autoconf failed...')
|
||||
|
||||
def automake(parameters = ''):
|
||||
'''generates a makefile'''
|
||||
if system('automake %s' % parameters):
|
||||
raise RunTimeError("!!!! Running automake failed...")
|
||||
raise RunTimeError('!!! Running automake failed...')
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
# any later version.
|
||||
#
|
||||
# Please read the COPYING file.
|
||||
#
|
||||
|
||||
# Standard Python Modules
|
||||
import sys
|
||||
@@ -17,7 +16,7 @@ import re
|
||||
from itertools import izip, imap, count, ifilter, ifilterfalse
|
||||
|
||||
# ActionsAPI
|
||||
import pisi.actionsapi as actionsapi
|
||||
import pisi.actionsapi
|
||||
|
||||
def cat(filename):
|
||||
return file(filename).xreadlines()
|
||||
|
||||
+10
-3
@@ -9,7 +9,6 @@
|
||||
# any later version.
|
||||
#
|
||||
# Please read the COPYING file.
|
||||
#
|
||||
|
||||
# Standart Python Modules
|
||||
import os.path
|
||||
@@ -91,6 +90,15 @@ def localstateDIR():
|
||||
def defaultprefixDIR():
|
||||
return dirs.defaultprefix
|
||||
|
||||
def kdeDIR():
|
||||
return dirs.kde
|
||||
|
||||
def qtDIR():
|
||||
return dirs.qt
|
||||
|
||||
def qtLIBDIR():
|
||||
return '%s/lib/' % qtDIR()
|
||||
|
||||
# Binutils Variables
|
||||
|
||||
def exists_binary(bin):
|
||||
@@ -105,10 +113,9 @@ def getBinutilsInfo(util):
|
||||
cross_build_name = '%s-%s' % (HOST(), util)
|
||||
if not exists_binary(cross_build_name):
|
||||
if not exists_binary(util):
|
||||
#ui.error('Error: util %s cannot be found' % util)
|
||||
raise BinutilsError('util %s cannot be found' % util)
|
||||
else:
|
||||
ui.debug('Warning: %s does not exist, using plain name %s'
|
||||
ui.debug('Warning: %s does not exist, using plain name %s' \
|
||||
% (cross_build_name, util))
|
||||
return util
|
||||
else:
|
||||
|
||||
+39
-23
@@ -9,44 +9,60 @@
|
||||
# any later version.
|
||||
#
|
||||
# Please read the COPYING file.
|
||||
#
|
||||
|
||||
# standard python modules
|
||||
import os
|
||||
|
||||
# actions api modules
|
||||
from pisi.actionsapi.actionglobals import glb
|
||||
# Pisi Modules
|
||||
from pisi.ui import ui
|
||||
|
||||
# Global variables for compiling KDE programs...
|
||||
kde_dir = os.getenv('KDEDIR')
|
||||
qt_dir = os.getenv('QTDIR')
|
||||
qt_libdir = os.path.join(os.getenv('QTDIR') + '/lib/')
|
||||
# ActionsAPI Modules
|
||||
import pisi.actionsapi
|
||||
import pisi.actionsapi.get as get
|
||||
from pisi.actionsapi.shelltools import system
|
||||
|
||||
class ConfigureError(pisi.actionsapi.Error):
|
||||
def __init__(self, Exception):
|
||||
ui.error(Exception)
|
||||
if can_access_file('config.log'):
|
||||
ui.error('\n!!! Please attach the config.log to your bug report:\n%s/config.log\n' % os.getcwd())
|
||||
|
||||
class MakeError(pisi.actionsapi.Error):
|
||||
def __init__(self, Exception):
|
||||
ui.error(Exception)
|
||||
|
||||
class InstallError(pisi.actionsapi.Error):
|
||||
def __init__(self, Exception):
|
||||
ui.error(Exception)
|
||||
|
||||
def configure(parameters = ''):
|
||||
''' FIXME: Düzgün hale getirilecek '''
|
||||
''' parameters = '--with-nls --with-libusb --with-something-usefull '''
|
||||
|
||||
configure_string = './configure --prefix=%s \
|
||||
if can_access_file('configure'):
|
||||
args = './configure \
|
||||
--prefix=%s \
|
||||
--host=%s \
|
||||
--with-x \
|
||||
--enable-mitshm \
|
||||
--with-qt-dir=%s \
|
||||
--enable-mt \
|
||||
--with-qt-libraries=%s \
|
||||
%s' % (kde_dir, glb.env.host, qt_dir, qt_libdir, parameters)
|
||||
%s' % (get.kdeDIR(), get.HOST(), get.qtDIR(), get.qtLIBDIR(), parameters)
|
||||
|
||||
os.system(configure_string)
|
||||
if system(args):
|
||||
raise ConfigureError('!!! Configure failed...\n')
|
||||
else:
|
||||
raise ConfigureError('!!! No configure script found...\n')
|
||||
|
||||
def make():
|
||||
''' FIXME: Düzgün hale getirilecek '''
|
||||
os.system('make')
|
||||
def make(parameters = ''):
|
||||
'''make source with given parameters = "all" || "doc" etc.'''
|
||||
if system('make %s' % parameters):
|
||||
raise MakeError('!!! Make failed...\n')
|
||||
|
||||
def install():
|
||||
''' FIXME: Düzgün hale getirilecek '''
|
||||
''' dir_suffix = /var/tmp/pisi/ _paket_adı_ /image/ '''
|
||||
|
||||
dir_suffix = os.path.dirname(os.path.dirname(os.getcwd())) + \
|
||||
glb.const.install_dir_suffix
|
||||
|
||||
install_string = 'make prefix=%s/%s install' % (dir_suffix, kde_dir)
|
||||
os.system(install_string)
|
||||
if can_access_file('Makefile'):
|
||||
args = 'make prefix=%s/%s install' % (get.installDIR(), get.kdeDIR())
|
||||
|
||||
if system(args):
|
||||
raise InstallError('!!! Install failed...\n')
|
||||
else:
|
||||
raise InstallError('!!! No Makefile found...\n')
|
||||
|
||||
+12
-14
@@ -9,18 +9,16 @@
|
||||
# any later version.
|
||||
#
|
||||
# Please read the COPYING file.
|
||||
#
|
||||
|
||||
# Standard Python Modules
|
||||
import os
|
||||
import shutil
|
||||
|
||||
# Pisi-Core Modules
|
||||
from pisi.ui import ui
|
||||
|
||||
# ActionsAPI Modules
|
||||
import pisi.actionsapi
|
||||
from pisi.actionsapi.shelltools import chmod, makedirs, can_access_directory
|
||||
from pisi.actionsapi.shelltools import *
|
||||
import pisi.actionsapi.get as get
|
||||
|
||||
class RunTimeError(pisi.actionsapi.Error):
|
||||
@@ -28,9 +26,10 @@ class RunTimeError(pisi.actionsapi.Error):
|
||||
ui.error(Exception)
|
||||
|
||||
def preplib(sourceDirectory = '/usr/lib'):
|
||||
sourceDirectory = '%s' % (get.installDIR() + sourceDirectory)
|
||||
sourceDirectory = get.installDIR() + sourceDirectory
|
||||
if can_access_directory(sourceDirectory):
|
||||
os.system('/sbin/ldconfig -n -N %s' % sourceDirectory)
|
||||
if system('/sbin/ldconfig -n -N %s' % sourceDirectory):
|
||||
raise RunTimeError('!!! Running ldconfig failed...')
|
||||
|
||||
def preplib_so(sourceDirectory):
|
||||
pass
|
||||
@@ -39,20 +38,19 @@ def gnuconfig_update():
|
||||
''' copy newest config.* onto source's '''
|
||||
for root, dirs, files in os.walk(os.getcwd()):
|
||||
for file in files:
|
||||
if file == "config.sub" or file == "config.guess":
|
||||
shutil.copyfile('/usr/share/gnuconfig/%s' % file, os.path.join(root, file))
|
||||
|
||||
ui.info('GNU Config Update Finished...\n')
|
||||
if file in ['config.sub', 'config.guess']:
|
||||
copy('/usr/share/gnuconfig/%s' % file, os.path.join(root, file))
|
||||
ui.info('GNU Config Update Finished...\n')
|
||||
|
||||
def libtoolize(parameters = ''):
|
||||
if os.system('/usr/bin/libtoolize %s' % parameters):
|
||||
raise RunTimeError("!!!! Running libtoolize failed...")
|
||||
if system('/usr/bin/libtoolize %s' % parameters):
|
||||
raise RunTimeError('!!! Running libtoolize failed...')
|
||||
|
||||
def gen_usr_ldscript(dynamicLib):
|
||||
|
||||
makedirs(get.installDIR() + '/usr/lib')
|
||||
makedirs('%s/usr/lib' % get.installDIR())
|
||||
|
||||
destinationFile = open(get.installDIR() + '/usr/lib/' + dynamicLib, 'w')
|
||||
destinationFile = open('%s/usr/lib/%s' % (get.installDIR(), dynamicLib), 'w')
|
||||
content = '''
|
||||
/* GNU ld script
|
||||
Since Pardus has critical dynamic libraries
|
||||
@@ -65,4 +63,4 @@ GROUP ( /lib/%s )
|
||||
|
||||
destinationFile.write(content)
|
||||
destinationFile.close()
|
||||
chmod(get.installDIR() + '/usr/lib/' + dynamicLib)
|
||||
chmod('%s/usr/lib/%s' % (get.installDIR(), dynamicLib))
|
||||
|
||||
@@ -9,16 +9,17 @@
|
||||
# any later version.
|
||||
#
|
||||
# Please read the COPYING file.
|
||||
#
|
||||
|
||||
# Standart Python Modules
|
||||
import os
|
||||
import glob
|
||||
import sys
|
||||
import shutil
|
||||
import fileinput
|
||||
import re
|
||||
|
||||
# Pisi Modules
|
||||
from pisi.ui import ui
|
||||
|
||||
# ActionsAPI Modules
|
||||
import pisi.actionsapi
|
||||
import pisi.actionsapi.get as get
|
||||
@@ -66,13 +67,13 @@ def dohtml(*sourceFiles):
|
||||
for sourceFile in sourceFiles:
|
||||
for source in glob.glob(sourceFile):
|
||||
if os.path.isfile(source) and os.path.splitext(source)[1] in allowed_extensions:
|
||||
os.system('install -m0644 %s %s' % (source, destionationDirectory))
|
||||
system('install -m0644 %s %s' % (source, destionationDirectory))
|
||||
if os.path.isdir(source) and os.path.basename(source) not in disallowed_directories:
|
||||
for root, dirs, files in os.walk(source):
|
||||
for source in files:
|
||||
if os.path.splitext(source)[1] in allowed_extensions:
|
||||
makedirs(destionationDirectory)
|
||||
os.system('install -m0644 %s %s' % (os.path.join(root, source), destionationDirectory))
|
||||
system('install -m0644 %s %s' % (os.path.join(root, source), destionationDirectory))
|
||||
|
||||
def doinfo(*sourceFiles):
|
||||
'''inserts the into files in the list of files into /usr/share/info'''
|
||||
@@ -87,7 +88,6 @@ def dolib(sourceFile, destinationDirectory = '/usr/lib'):
|
||||
|
||||
'''example call: pisitools.dolib_a("libz.a")'''
|
||||
'''example call: pisitools.dolib_a("libz.so")'''
|
||||
#FIXME: Glob needed?
|
||||
sourceFile = os.path.join(os.getcwd(), sourceFile)
|
||||
destinationDirectory = get.installDIR() + destinationDirectory
|
||||
|
||||
@@ -97,7 +97,6 @@ def dolib_a(sourceFile, destinationDirectory = '/usr/lib'):
|
||||
'''insert the static library into /usr/lib with permission 0644'''
|
||||
|
||||
'''example call: pisitools.dolib_a("staticlib/libvga.a")'''
|
||||
#FIXME: Glob needed?
|
||||
sourceFile = os.path.join(os.getcwd(), sourceFile)
|
||||
destinationDirectory = get.installDIR() + destinationDirectory
|
||||
|
||||
@@ -107,7 +106,6 @@ def dolib_so(sourceFile, destinationDirectory = '/usr/lib'):
|
||||
'''insert the static library into /usr/lib with permission 0755'''
|
||||
|
||||
'''example call: pisitools.dolib_so("pppd/plugins/minconn.so")'''
|
||||
#FIXME: Glob needed?
|
||||
sourceFile = os.path.join(os.getcwd(), sourceFile)
|
||||
destinationDirectory = get.installDIR() + destinationDirectory
|
||||
|
||||
@@ -127,20 +125,19 @@ def doman(*sourceFiles):
|
||||
pageName, pageDirectory = source[:source.rindex('.')], \
|
||||
source[source.rindex('.')+1:]
|
||||
except ValueError:
|
||||
print 'doman: Wrong man page file'
|
||||
sys.exit(1)
|
||||
ui.error('\n!!! ActionsAPI [doman]: Wrong man page file...\n')
|
||||
|
||||
makedirs(manDIR + '/man%s' % pageDirectory)
|
||||
os.system('install -m0644 %s %s' % (source, manDIR + '/man%s' % pageDirectory))
|
||||
system('install -m0644 %s %s' % (source, manDIR + '/man%s' % pageDirectory))
|
||||
|
||||
def domo(sourceFile, locale, destinationFile ):
|
||||
'''inserts the mo files in the list of files into /usr/share/locale/LOCALE/LC_MESSAGES'''
|
||||
|
||||
'''example call: pisitools.domo("po/tr.po", "tr", "pam_login.mo")'''
|
||||
|
||||
system("msgfmt %s" % sourceFile)
|
||||
makedirs(get.installDIR() + "/usr/share/locale/%s/LC_MESSAGES/" % locale)
|
||||
shutil.move("messages.mo", get.installDIR() + "/usr/share/locale/%s/LC_MESSAGES/%s" % (locale, destinationFile))
|
||||
system('msgfmt %s' % sourceFile)
|
||||
makedirs('%s/usr/share/locale/%s/LC_MESSAGES/' % (get.installDIR(), locale))
|
||||
move('messages.mo', '%s/usr/share/locale/%s/LC_MESSAGES/%s' % (get.installDIR(), locale, destinationFile))
|
||||
|
||||
def domove(sourceFile, destination, destinationFile = ''):
|
||||
'''moves sourceFile/Directory into destinationFile/Directory'''
|
||||
@@ -151,9 +148,9 @@ def domove(sourceFile, destination, destinationFile = ''):
|
||||
|
||||
for file in glob.glob(get.installDIR() + sourceFile):
|
||||
if not destinationFile:
|
||||
shutil.move(file, get.installDIR() + os.path.join(destination, os.path.basename(file)))
|
||||
move(file, get.installDIR() + os.path.join(destination, os.path.basename(file)))
|
||||
else:
|
||||
shutil.move(file, get.installDIR() + os.path.join(destination, destinationFile))
|
||||
move(file, get.installDIR() + os.path.join(destination, destinationFile))
|
||||
|
||||
def dopython():
|
||||
'''FIXME: What the hell is this?'''
|
||||
@@ -168,6 +165,7 @@ def dosed(sourceFile, findPattern, replacePattern = ''):
|
||||
|
||||
if can_access_file(sourceFile):
|
||||
for line in fileinput.input(sourceFile, inplace = 1):
|
||||
#FIXME: In-place filtering is disabled when standard input is read
|
||||
line = re.sub(findPattern, replacePattern, line)
|
||||
sys.stdout.write(line)
|
||||
else:
|
||||
@@ -188,9 +186,7 @@ def dosym(sourceFile, destinationFile):
|
||||
try:
|
||||
os.symlink(sourceFile, get.installDIR() + destinationFile)
|
||||
except OSError:
|
||||
print 'dosym: File exists...'
|
||||
|
||||
''' ************************************************************************** '''
|
||||
ui.error('\n!!! ActionsAPI [dosym]: File exists...\n')
|
||||
|
||||
def insinto(destinationDirectory, sourceFile, destinationFile = ''):
|
||||
'''insert a sourceFile into destinationDirectory as a destinationFile with same uid/guid/permissions'''
|
||||
@@ -199,24 +195,20 @@ def insinto(destinationDirectory, sourceFile, destinationFile = ''):
|
||||
if not destinationFile:
|
||||
for file in glob.glob(sourceFile):
|
||||
if can_access_file(file):
|
||||
shutil.copy(file, get.installDIR() + os.path.join(destinationDirectory, os.path.basename(file)))
|
||||
copy(file, get.installDIR() + os.path.join(destinationDirectory, os.path.basename(file)))
|
||||
else:
|
||||
shutil.copy(sourceFile, get.installDIR() + os.path.join(destinationDirectory, destinationFile))
|
||||
|
||||
''' ************************************************************************** '''
|
||||
copy(sourceFile, get.installDIR() + os.path.join(destinationDirectory, destinationFile))
|
||||
|
||||
def newdoc(sourceFile, destinationFile):
|
||||
'''inserts a sourceFile into /usr/share/doc/PACKAGE/ directory as a destinationFile'''
|
||||
shutil.move(sourceFile, destinationFile)
|
||||
move(sourceFile, destinationFile)
|
||||
readable_insinto(os.path.join(get.installDIR(), 'usr/share/doc', get.srcTAG()), destinationFile)
|
||||
|
||||
def newman(sourceFile, destinationFile):
|
||||
'''inserts a sourceFile into /usr/share/man/manPREFIX/ directory as a destinationFile'''
|
||||
shutil.move(sourceFile, destinationFile)
|
||||
move(sourceFile, destinationFile)
|
||||
doman(destinationFile)
|
||||
|
||||
''' ************************************************************************** '''
|
||||
|
||||
def remove(sourceFile):
|
||||
'''removes sourceFile'''
|
||||
unlink(get.installDIR() + sourceFile)
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
# any later version.
|
||||
#
|
||||
# Please read the COPYING file.
|
||||
#
|
||||
|
||||
# Generic functions for common usage of pisitools #
|
||||
|
||||
@@ -38,11 +37,10 @@ def executable_insinto(sourceFile, destinationDirectory):
|
||||
if not can_access_file(sourceFile):
|
||||
raise FileError('File doesn\'t exists or permission denied...')
|
||||
|
||||
if can_access_directory(destinationDirectory) and os.path.isdir(destinationDirectory):
|
||||
os.system('install -m0755 -o root -g root %s %s' % (sourceFile, destinationDirectory))
|
||||
else:
|
||||
if not can_access_directory(destinationDirectory):
|
||||
makedirs(destinationDirectory)
|
||||
os.system('install -m0755 -o root -g root %s %s' % (sourceFile, destinationDirectory))
|
||||
|
||||
system('install -m0755 -o root -g root %s %s' % (sourceFile, destinationDirectory))
|
||||
|
||||
def readable_insinto(destinationDirectory, *sourceFiles):
|
||||
'''inserts file list into destinationDirectory'''
|
||||
@@ -55,7 +53,7 @@ def readable_insinto(destinationDirectory, *sourceFiles):
|
||||
|
||||
for sourceFile in sourceFiles:
|
||||
for source in glob.glob(sourceFile):
|
||||
os.system('install -m0644 %s %s' % (source, destinationDirectory))
|
||||
system('install -m0644 %s %s' % (source, destinationDirectory))
|
||||
|
||||
def lib_insinto(sourceFile, destinationDirectory, permission = 0644):
|
||||
'''inserts a library fileinto destinationDirectory with given permission'''
|
||||
@@ -69,4 +67,4 @@ def lib_insinto(sourceFile, destinationDirectory, permission = 0644):
|
||||
if os.path.islink(sourceFile):
|
||||
os.symlink(os.path.realpath(sourceFile), os.path.join(destinationDirectory, sourceFile))
|
||||
else:
|
||||
os.system('install -m%s %s %s' % (permission, sourceFile, destinationDirectory))
|
||||
system('install -m%s %s %s' % (permission, sourceFile, destinationDirectory))
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
# any later version.
|
||||
#
|
||||
# Please read the COPYING file.
|
||||
#
|
||||
|
||||
# Standart Python Modules
|
||||
import os
|
||||
@@ -41,29 +40,82 @@ def makedirs(destinationDirectory):
|
||||
def chmod(sourceFile, mode = 0755):
|
||||
'''change the mode of sourceFile to the mode'''
|
||||
for file in glob.glob(sourceFile):
|
||||
os.chmod(file, mode)
|
||||
|
||||
if can_access_file(file):
|
||||
try:
|
||||
os.chmod(file, mode)
|
||||
except OSError:
|
||||
ui.error('\n!!! ActionsAPI [chmod]: Operation not permitted...\n')
|
||||
else:
|
||||
ui.error('\n!!! ActionsAPI [chmod]: File doesn\'t exists...\n')
|
||||
|
||||
def chown(sourceFile, uid = 0, gid = 0):
|
||||
'''change the owner and group id of sourceFile to the numeric uid and gid'''
|
||||
if can_access_file(sourceFile):
|
||||
try:
|
||||
os.chown(sourceFile, uid, gid)
|
||||
except OSError:
|
||||
ui.error('\n!!! ActionsAPI [chown]: Operation not permitted...\n')
|
||||
else:
|
||||
ui.error('\n!!! ActionsAPI [chown]: File doesn\'t exists...\n')
|
||||
|
||||
def sym(sourceFile, destinationFile):
|
||||
'''creates symbolic link'''
|
||||
try:
|
||||
os.symlink(sourceFile, destinationFile)
|
||||
except OSError:
|
||||
ui.error('\n!!! ActionsAPI [sym]: Permission denied...\n')
|
||||
|
||||
def unlink(sourceFile):
|
||||
os.unlink(sourceFile)
|
||||
'''remove the file path'''
|
||||
if isFile(sourceFile) or isLink(sourceFile):
|
||||
try:
|
||||
os.unlink(sourceFile)
|
||||
except OSError:
|
||||
ui.error('\n!!! ActionsAPI [unlink]: Permission denied...\n')
|
||||
else:
|
||||
ui.error('\n!!! ActionsAPI [unlink]: File doesn\'t exists...\n')
|
||||
|
||||
def unlinkDir(sourceDirectory):
|
||||
if can_access_directory(sourceDirectory):
|
||||
shutil.rmtree(sourceDirectory)
|
||||
'''delete an entire directory tree'''
|
||||
if isDirectory(sourceDirectory) or isLink(sourceDirectory):
|
||||
try:
|
||||
shutil.rmtree(sourceDirectory)
|
||||
except OSError:
|
||||
ui.error('\n!!! ActionsAPI [unlinkDir]: Operation not permitted...\n')
|
||||
else:
|
||||
ui.error('unlinkDir: remove failed...')
|
||||
ui.error('\n!!! ActionsAPI [unlinkDir]: File doesn\'t exists...\n')
|
||||
|
||||
def move(sourceFile, destinationFile):
|
||||
'''recursively move a sourceFile or directory to destinationFile'''
|
||||
for file in glob.glob(sourceFile):
|
||||
shutil.move(file, destinationFile)
|
||||
if can_access_file(file):
|
||||
try:
|
||||
shutil.move(file, destinationFile)
|
||||
except OSError:
|
||||
ui.error('\n!!! ActionsAPI [move]: Permission denied...\n')
|
||||
else:
|
||||
ui.error('\n!!! ActionsAPI [move]: File doesn\'t exists...\n')
|
||||
|
||||
def copy(sourceFile, destinationFile):
|
||||
'''recursively copy a sourceFile or directory to destinationFile'''
|
||||
for file in glob.glob(sourceFile):
|
||||
shutil.copy(file, destinationFile)
|
||||
if can_access_file(file):
|
||||
try:
|
||||
shutil.copy(file, destinationFile)
|
||||
except IOError:
|
||||
ui.error('\n!!! ActionsAPI [copy]: Permission denied...\n')
|
||||
else:
|
||||
ui.error('\n!!! ActionsAPI [copy]: File doesn\'t exists...\n')
|
||||
|
||||
def copytree(source, destination, sym=False):
|
||||
shutil.copytree(source, destination, sym)
|
||||
def copytree(source, destination, sym = False):
|
||||
'''recursively copy an entire directory tree rooted at source'''
|
||||
if can_access_directory(source):
|
||||
try:
|
||||
shutil.copytree(source, destination, sym)
|
||||
except OSError:
|
||||
ui.error('\n!!! ActionsAPI [copytree]: Permission denied...\n')
|
||||
else:
|
||||
ui.error('\n!!! ActionsAPI [copytree]: Directory doesn\'t exists...\n')
|
||||
|
||||
def touch(sourceFile):
|
||||
'''changes the access time of the 'sourceFile', or creates it if it is not exist'''
|
||||
@@ -71,8 +123,11 @@ def touch(sourceFile):
|
||||
for file in glob.glob(sourceFile):
|
||||
os.utime(file, None)
|
||||
else:
|
||||
f = open(sourceFile, 'w')
|
||||
f.close()
|
||||
try:
|
||||
f = open(sourceFile, 'w')
|
||||
f.close()
|
||||
except IOError:
|
||||
ui.error('\n!!! ActionsAPI [touch]: Permission denied...\n')
|
||||
|
||||
def cd(directoryName = ''):
|
||||
'''change directory'''
|
||||
@@ -90,9 +145,36 @@ def ls(source):
|
||||
return glob.glob(source)
|
||||
|
||||
def export(key, value):
|
||||
'''export environ variable'''
|
||||
os.environ[key] = value
|
||||
|
||||
def isLink(sourceFile):
|
||||
'''return True if sourceFile refers to a symbolic link'''
|
||||
return os.path.islink(sourceFile)
|
||||
|
||||
def isFile(sourceFile):
|
||||
'''return True if sourceFile is an existing regular file'''
|
||||
return os.path.isfile(sourceFile)
|
||||
|
||||
def isDirectory(sourceFile):
|
||||
'''Return True if sourceFile is an existing directory'''
|
||||
return os.path.isdir(sourceFile)
|
||||
|
||||
def realPath(sourceFile):
|
||||
'''return the canonical path of the specified filename, eliminating any symbolic links encountered in the path'''
|
||||
return os.path.realpath(sourceFile)
|
||||
|
||||
def baseName(sourceFile):
|
||||
'''return the base name of pathname sourceFile'''
|
||||
return os.path.basename(sourceFile)
|
||||
|
||||
def dirName(sourceFile):
|
||||
'''return the directory name of pathname path'''
|
||||
return os.path.dirname(sourceFile)
|
||||
|
||||
def system(command):
|
||||
#FIXME: String formatting
|
||||
command = command.replace(" ", " ")
|
||||
ui.debug('executing %s\n' % command)
|
||||
p = os.popen(command)
|
||||
while 1:
|
||||
@@ -102,19 +184,3 @@ def system(command):
|
||||
ui.debug(line)
|
||||
|
||||
return p.close()
|
||||
|
||||
def isLink(sourceFile):
|
||||
return os.path.islink(sourceFile)
|
||||
|
||||
def realPath(sourceFile):
|
||||
return os.path.realpath(sourceFile)
|
||||
|
||||
def baseName(sourceFile):
|
||||
return os.path.basename(sourceFile)
|
||||
|
||||
def dirName(sourceFile):
|
||||
return os.path.dirname(sourceFile)
|
||||
|
||||
def sym(sourceFile, destinationFile):
|
||||
os.symlink(sourceFile, destinationFile)
|
||||
|
||||
|
||||
@@ -9,14 +9,13 @@
|
||||
# any later version.
|
||||
#
|
||||
# Please read the COPYING file.
|
||||
#
|
||||
|
||||
# Standard Python Modules
|
||||
from os import getenv, environ
|
||||
|
||||
# Pisi-Core Modules
|
||||
import pisi.config # That was the only correct
|
||||
import pisi.constants # use before changing to abs. imports
|
||||
import pisi.config
|
||||
import pisi.constants
|
||||
|
||||
# Set individual information, that are generally needed for ActionsAPI
|
||||
|
||||
@@ -72,6 +71,10 @@ class Dirs:
|
||||
localstate = 'var/lib'
|
||||
defaultprefix = 'usr'
|
||||
|
||||
#FIXME: Get these from config or somewhere else!
|
||||
kde = '/usr/kde/3.4'
|
||||
qt = '/usr/qt/3'
|
||||
|
||||
class Variables(pisi.config.Config):
|
||||
const = pisi.constants.const
|
||||
env = Env()
|
||||
|
||||
Reference in New Issue
Block a user