# -*- coding: utf-8 -*- # # (c) Copyright @ 2015 HP Development Company, L.P. # # This program 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 2 of the License, or # (at your option) any later version. # # This program 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 this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Author: Amarnath Chitumalla, Goutam Kodu # # Global import import os import os.path import locale import stat #Local from . import logger log = logger.Logger('', logger.Logger.LOG_LEVEL_INFO, logger.Logger.LOG_TO_CONSOLE) def execute(cmd): if cmd: return os.system(cmd) else: log.error("Command not found \n" % cmd) return 127 # Returns the file size in bytes. # If file is not exists, returns size as -1. # def getFileSize(filename): if not os.path.exists(filename): return -1 return os.path.getsize(filename) def getHPLIPDir(): homedir = os.path.expanduser('~') hplipdir = os.path.join(homedir, ".hplip") status = 0 if not os.path.exists(hplipdir): try: os.umask(0) s = os.stat(homedir) os.mkdir(hplipdir, 0o755) os.chown(hplipdir, s[stat.ST_UID], s[stat.ST_GID]) except OSError: status = 1 log.error("Failed to create %s" % hplipdir) return status, hplipdir def changeOwner(path, user, group, Recursive = False ): status = 0 try: if Recursive: for root, dirs, files in os.walk(path): for dr in dirs: os.chown(os.path.join(root, dr), user, group) for fl in files: os.chown(os.path.join(root, fl), user, group) else: os.chown(path, user, group) except OSError: status = 1 log.error("Failed to change ownership of %s" %path) return status
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
__pycache__ | Folder | 0755 |
|
|
pexpect | Folder | 0755 |
|
|
LedmWifi.py | File | 29.18 KB | 0644 |
|
__init__.py | File | 785 B | 0644 |
|
avahi.py | File | 3.01 KB | 0644 |
|
codes.py | File | 30.55 KB | 0644 |
|
device.py | File | 95.38 KB | 0644 |
|
dime.py | File | 3.3 KB | 0644 |
|
exif.py | File | 35.08 KB | 0644 |
|
g.py | File | 14.19 KB | 0644 |
|
imageprocessing.py | File | 33.14 KB | 0644 |
|
imagesize.py | File | 5.75 KB | 0644 |
|
ldif.py | File | 16.33 KB | 0644 |
|
logger.py | File | 18.06 KB | 0644 |
|
magic.py | File | 63.2 KB | 0644 |
|
maint.py | File | 58.36 KB | 0644 |
|
mdns.py | File | 10.04 KB | 0644 |
|
mfpdtf.py | File | 17.34 KB | 0644 |
|
models.py | File | 19.04 KB | 0644 |
|
module.py | File | 28.32 KB | 0644 |
|
os_utils.py | File | 2.28 KB | 0644 |
|
password.py | File | 12.73 KB | 0644 |
|
pkit.py | File | 11.45 KB | 0644 |
|
pml.py | File | 26.46 KB | 0644 |
|
queues.py | File | 16.35 KB | 0644 |
|
services.py | File | 9.74 KB | 0644 |
|
six.py | File | 22.32 KB | 0644 |
|
sixext.py | File | 5.78 KB | 0644 |
|
slp.py | File | 5.8 KB | 0644 |
|
smart_install.py | File | 11.37 KB | 0644 |
|
status.py | File | 76.35 KB | 0644 |
|
strings.py | File | 28.21 KB | 0644 |
|
tui.py | File | 13.79 KB | 0644 |
|
utils.py | File | 75.97 KB | 0644 |
|
validation.py | File | 3.68 KB | 0644 |
|
vcard.py | File | 43.66 KB | 0644 |
|
wifi.py | File | 22.25 KB | 0644 |
|