Skip to content

Commit

Permalink
pep8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kormoc committed May 24, 2013
1 parent 8fe8a01 commit 5fdf24a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 29 deletions.
20 changes: 10 additions & 10 deletions bin/diamond
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import os
import sys
import configobj
if os.name != 'nt':
import pwd
import grp
import pwd
import grp

try:
from setproctitle import setproctitle
Expand Down Expand Up @@ -195,17 +195,17 @@ def main():

# Get final GIDs
if os.name != 'nt':
if options.group is not None:
gid = grp.getgrnam(options.group).gr_gid
elif len(config['server']['group']):
gid = grp.getgrnam(config['server']['group']).gr_gid
if options.group is not None:
gid = grp.getgrnam(options.group).gr_gid
elif len(config['server']['group']):
gid = grp.getgrnam(config['server']['group']).gr_gid

# Get final UID
if os.name != 'nt':
if options.user is not None:
uid = pwd.getpwnam(options.user).pw_uid
elif len(config['server']['user']):
uid = pwd.getpwnam(config['server']['user']).pw_uid
if options.user is not None:
uid = pwd.getpwnam(options.user).pw_uid
elif len(config['server']['user']):
uid = pwd.getpwnam(config['server']['user']).pw_uid

# Fix up pid permissions
if not options.foreground and not options.collector:
Expand Down
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
(os.path.join(base_files, 'handlers'), glob('conf/handlers/*')),
]
install_requires = ['ConfigObj', 'psutil', ],

else:
data_files = [
('share/diamond', ['LICENSE', 'README.md', 'version.txt']),
('share/diamond/user_scripts', []),
]

distro = platform.dist()[0]
distro_major_version = platform.dist()[1].split('.')[0]

if os.getenv('VIRTUAL_ENV', False):
data_files.append(('etc/diamond',
glob('conf/*.conf.*')))
Expand All @@ -48,7 +48,7 @@
glob('conf/collectors/*')))
data_files.append(('/etc/diamond/handlers',
glob('conf/handlers/*')))

if distro == 'Ubuntu':
data_files.append(('/etc/init',
['debian/upstart/diamond.conf']))
Expand All @@ -60,7 +60,7 @@
if distro_major_version >= '6' and not distro == 'debian':
data_files.append(('/etc/init',
['rpm/upstart/diamond.conf']))

# Support packages being called differently on different distros
if distro in ['centos', 'redhat']:
install_requires = ['python-configobj', 'psutil', ],
Expand Down Expand Up @@ -108,7 +108,7 @@ def pkgPath(root, path, rpath="/"):
pkgPath(root, subpath, spath)

if os.name == 'nt':
pkgPath(os.path.join(base_files, 'collectors'), 'src/collectors', '\\')
pkgPath(os.path.join(base_files, 'collectors'), 'src/collectors', '\\')
else:
pkgPath('share/diamond/collectors', 'src/collectors')

Expand Down
19 changes: 10 additions & 9 deletions src/collectors/diskspace/diskspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,29 +198,30 @@ def collect(self):

if hasattr(os, 'statvfs'): # POSIX
data = os.statvfs(info['mount_point'])

block_size = data.f_bsize

blocks_total = data.f_blocks
blocks_free = data.f_bfree
blocks_avail = data.f_bavail
inodes_total = data.f_files
inodes_free = data.f_ffree
inodes_avail = data.f_favail

elif os.name == 'nt': # Windows
# fixme: used still not exact compared to disk_usage.py from psutil
# fixme: used still not exact compared to disk_usage.py
# from psutil
raw_data = psutil.disk_usage(info['mount_point'])
block_size = 1 # fixme: ?

block_size = 1 # fixme: ?

blocks_total = raw_data.total
blocks_free = raw_data.free
blocks_used = raw_data.used

else:
raise NotImplementedError("platform not supported")

for unit in self.config['byte_unit']:

metric_name = '%s.%s_used' % (name, unit)
Expand Down
3 changes: 2 additions & 1 deletion src/collectors/libvirtkvm/libvirtkvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@

try:
import libvirt
libvirt # Pyflakes
libvirt # Pyflakes
except ImportError:
libvirt = None


class LibvirtKVMCollector(diamond.collector.Collector):
blockStats = {
'read_reqs': 0,
Expand Down
2 changes: 1 addition & 1 deletion src/collectors/vmsdoms/vmsdoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import diamond.collector
try:
import vms
vms # Pyflakes
vms # Pyflakes
except ImportError:
vms = None

Expand Down
5 changes: 3 additions & 2 deletions src/diamond/logging/handlers/timedrotating.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
from logging.handlers import TimedRotatingFileHandler as TRFH
import sys


class TimedRotatingFileHandler(TRFH):
def flush():

def flush(self):
try:
super(TimedRotatingFileHandler, self).flush()
except IOError:
Expand Down

0 comments on commit 5fdf24a

Please sign in to comment.