Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use futurize to have python 3 compatible print with import #8

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion plugin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
from Components.Language import language
from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE
from os import environ as os_environ
Expand All @@ -14,7 +15,7 @@ def localeInit():
def _(txt):
t = gettext.dgettext("CacheFlush", txt)
if t == txt:
print "[CacheFlush] fallback to default translation for", txt
print("[CacheFlush] fallback to default translation for", txt)
t = gettext.gettext(txt)
return t

Expand Down
25 changes: 13 additions & 12 deletions plugin/ui.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
# for localized messages
from . import _

Expand All @@ -24,8 +25,8 @@
try: # can be used ngettext ?
ngettext("%d minute", "%d minutes", 5)
NGETTEXT = True
except Exception, e:
print "[CacheFlush] ngettext is not supported:", e
except Exception as e:
print("[CacheFlush] ngettext is not supported:", e)
choicelist = []
for i in range(5, 151, 5):
if NGETTEXT:
Expand Down Expand Up @@ -55,28 +56,28 @@
def dropCache():
if cfg.sync.value:
system("sync")
print "[CacheFlush] sync"
print("[CacheFlush] sync")
if cfg.type.value == "1": # free pagecache
system("echo 1 > /proc/sys/vm/drop_caches")
print "[CacheFlush] free pagecache"
print("[CacheFlush] free pagecache")
elif cfg.type.value == "2": # free dentries and inodes
system("echo 2 > /proc/sys/vm/drop_caches")
print "[CacheFlush] free dentries and inodes"
print("[CacheFlush] free dentries and inodes")
elif cfg.type.value == "3": # free pagecache, dentries and inodes
system("echo 3 > /proc/sys/vm/drop_caches")
print "[CacheFlush] free pagecache, dentries and inodes"
print("[CacheFlush] free pagecache, dentries and inodes")


def getMinFreeKbytes():
for line in open('/proc/sys/vm/min_free_kbytes', 'r'):
line = line.strip()
print "[CacheFlush] min_free_kbytes is %s kB" % line
print("[CacheFlush] min_free_kbytes is %s kB" % line)
return line


def setMinFreeKbytes(size):
system("echo %d > /proc/sys/vm/min_free_kbytes" % (size))
print "[CacheFlush] set min_free_kbytes to %d kB" % size
print("[CacheFlush] set min_free_kbytes to %d kB" % size)


class CacheFlushSetupMenu(Screen, ConfigListScreen):
Expand Down Expand Up @@ -207,8 +208,8 @@ def getMemory(self, par=0x01):
self["slide"].setValue(int(100.0 * mu / mm + 0.25))
self["slide"].show()
return memory
except Exception, e:
print "[CacheFlush] getMemory FAIL:", e
except Exception as e:
print("[CacheFlush] getMemory FAIL:", e)
return ""

def memoryInfo(self):
Expand Down Expand Up @@ -386,8 +387,8 @@ def getMemInfo(self):
self['pfree'].setText("%.1f %s" % (100. * free / mem, '%'))
self['pused'].setText("%.1f %s" % (100. * (mem - free) / mem, '%'))

except Exception, e:
print "[CacheFlush] getMemory FAIL:", e
except Exception as e:
print("[CacheFlush] getMemory FAIL:", e)

def freeMemory(self):
dropCache()
Expand Down
5 changes: 3 additions & 2 deletions setup_translate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
# Language extension for distutils Python scripts. Based on this concept:
# http://wiki.maemo.org/Internationalize_a_Python_application
from distutils import cmd
Expand All @@ -23,9 +24,9 @@ def run(self):
if f.endswith('.po'):
src = os.path.join(lc, f)
dest = os.path.join(lc, f[:-2] + 'mo')
print "Language compile %s -> %s" % (src, dest)
print("Language compile %s -> %s" % (src, dest))
if os.system("msgfmt '%s' -o '%s'" % (src, dest)) != 0:
raise Exception, "Failed to compile: " + src
raise Exception("Failed to compile: " + src)


class build(_build):
Expand Down