~artfwo/indicator-cpufreq/trunk

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Launchpad Translations on behalf of artfwo
  • Date: 2013-03-04 05:34:16 UTC
  • Revision ID: launchpad_translations_on_behalf_of_artfwo-20130304053416-kf3ckd5uh9xq97hy
Launchpad automatic translations update.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3
 
### BEGIN LICENSE
4
 
# Copyright (C) 2010 Артём Попов <artfwo@gmail.com>
5
 
# This program is free software: you can redistribute it and/or modify it 
6
 
# under the terms of the GNU General Public License version 3, as published 
7
 
# by the Free Software Foundation.
8
 
9
 
# This program is distributed in the hope that it will be useful, but 
10
 
# WITHOUT ANY WARRANTY; without even the implied warranties of 
11
 
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
12
 
# PURPOSE.  See the GNU General Public License for more details.
13
 
14
 
# You should have received a copy of the GNU General Public License along 
15
 
# with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
### END LICENSE
17
 
 
18
 
###################### DO NOT TOUCH THIS (HEAD TO THE SECOND PART) ######################
19
 
 
 
1
#! /usr/bin/env python3
 
2
 
 
3
import DistUtilsExtra.auto
 
4
import glob
20
5
import os
21
 
import sys
22
 
 
23
 
try:
24
 
    import DistUtilsExtra.auto
25
 
except ImportError:
26
 
    print >> sys.stderr, 'To build indicator-cpufreq you need https://launchpad.net/python-distutils-extra'
27
 
    sys.exit(1)
28
 
assert DistUtilsExtra.auto.__version__ >= '2.18', 'needs DistUtilsExtra.auto >= 2.18'
29
 
 
30
 
def update_data_path(prefix, oldvalue=None):
31
 
 
32
 
    try:
33
 
        fin = file('indicator_cpufreq/indicator_cpufreqconfig.py', 'r')
34
 
        fout = file(fin.name + '.new', 'w')
35
 
 
36
 
        for line in fin:            
37
 
            fields = line.split(' = ') # Separate variable from value
38
 
            if fields[0] == '__indicator_cpufreq_data_directory__':
39
 
                # update to prefix, store oldvalue
40
 
                if not oldvalue:
41
 
                    oldvalue = fields[1]
42
 
                    line = "%s = '%s'\n" % (fields[0], prefix)
43
 
                else: # restore oldvalue
44
 
                    line = "%s = %s" % (fields[0], oldvalue)
45
 
            fout.write(line)
46
 
 
47
 
        fout.flush()
48
 
        fout.close()
49
 
        fin.close()
50
 
        os.rename(fout.name, fin.name)
51
 
    except (OSError, IOError), e:
52
 
        print ("ERROR: Can't find indicator_cpufreq/indicator_cpufreqconfig.py")
53
 
        sys.exit(1)
54
 
    return oldvalue
55
 
 
56
 
 
57
 
class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto):
58
 
    def run(self):
59
 
        previous_value = update_data_path(self.prefix + '/share/indicator-cpufreq/')
60
 
        DistUtilsExtra.auto.install_auto.run(self)
61
 
        update_data_path(self.prefix, previous_value)
62
 
 
63
 
 
64
 
        
65
 
##################################################################################
66
 
###################### YOU SHOULD MODIFY ONLY WHAT IS BELOW ######################
67
 
##################################################################################
68
 
 
69
 
import glob
 
6
from DistUtilsExtra.command import *
70
7
 
71
8
DistUtilsExtra.auto.setup(
72
9
    name='indicator-cpufreq',
73
 
    version='0.1.4',
 
10
    version='0.2',
74
11
    license='GPL-3',
75
 
    author='Артём Попов',
 
12
    author='Artem Popov',
76
13
    author_email='artfwo@gmail.com',
77
14
    description='CPU frequency scaling indicator',
78
15
    long_description='Indicator applet for displaying and changing CPU frequency on-the-fly.',
79
16
    url='https://launchpad.net/indicator-cpufreq',
80
 
    cmdclass={'install': InstallAndUpdateDataDirectory},
81
 
    # FIXME: install icons as data_files until we resolve it with quickly
 
17
    # install icons as data_files because distutils don't do that well
82
18
    data_files=[
83
19
        ('share/icons/ubuntu-mono-dark/status/22',
84
20
            glob.glob('icons/ubuntu-mono-dark/*')),
85
21
        ('share/icons/ubuntu-mono-light/status/22',
86
22
            glob.glob('icons/ubuntu-mono-light/*')),
 
23
        # temp fix for LP: #1125598
 
24
        ('share/icons/hicolor/22x22/status',
 
25
            glob.glob('icons/ubuntu-mono-dark/*')),
87
26
#        ('/var/lib/polkit-1/localauthority/10-vendor.d',
88
27
#            ['indicator-cpufreq.pkla']),
89
28
    ]