diff --git a/NeoBoot/files/tools.py b/NeoBoot/files/tools.py
index 508ed62..3c4ed75 100644
--- a/NeoBoot/files/tools.py
+++ b/NeoBoot/files/tools.py
@@ -1740,92 +1740,112 @@ class ATVcamfeed(Screen):
self.close()
-class TunerInfo(Screen):
- __module__ = __name__
- skin = """
-
-
-
- """
-
- def __init__(self, session):
- Screen.__init__(self, session)
- self['lab1'] = Label(_('List of supported stb.'))
- self['key_red'] = Label(_('Start - Red'))
- self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close,
- 'red': self.iNFO})
-
- def iNFO(self):
- try:
- cmd = ' cat ' + LinkNeoBoot + '/stbinfo.cfg'
- cmd1 = ''
- self.session.openWithCallback(self.close, Console, _('NeoBoot....'), [cmd,
- cmd1])
- self.close()
-
- except:
- False
-
-
class CreateSwap(Screen):
__module__ = __name__
- skin = """
-
-
-
+ skin = """
+
+
+
"""
- def __init__(self, session):
+ def __init__(self, session):
Screen.__init__(self, session)
self['lab1'] = Label(_('Create swap-file.'))
self['key_red'] = Label(_('Start create file swap.'))
+ self['key_green'] = Label(_('Remove file swap.'))
self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close,
- 'red': self.CreateSwap})
-
+ 'red': self.RemoveSwap,
+ 'green': self.CreateSwap})
+
def CreateSwap(self):
- if os.path.exists('/media/hdd/ImageBoot/.neonextboot'):
- if not os.path.exists('/media/hdd/swapfile'):
- cmd0 = "echo -e '\n\n%s '" % _('Creation swap 512MB, please wait...')
- cmd1 = 'dd if=/dev/zero of=/media/hdd/swapfile bs=1024 count=524288'
- cmd2 = 'mkswap /media/hdd/swapfile'
- cmd3 = 'swapon /media/hdd/swapfile'
- cmd4 = 'echo "/media/hdd/swapfile swap swap defaults 0 0 " >> /etc/fstab'
- cmd5 = 'echo "/sbin/swapon /hdd/swapfile; swapon -a " > /etc/init.d/rcS.local'
- cmd6 = 'chmod 755 /etc/init.d/rcS.local; chmod 755 /media/hdd/swapfile; /sbin/swapon /hdd/swapfile'
- cmd7 = "echo -e '\n\n%s '" % _('Creation complete swap 512MB')
- self.session.open(Console, _('NeoBoot....'), [cmd0,
- cmd1,
- cmd2,
- cmd3,
- cmd4,
- cmd5,
- cmd6,
- cmd7])
- else:
- self.myClose(_('The file swapfile already exists!'))
- elif os.path.exists('/media/usb/ImageBoot/.neonextboot'):
- if not os.path.exists('/media/usb/swapfile'):
- cmd0 = "echo -e '\n\n%s '" % _('Creation swap 512MB, please wait...')
- cmd1 = 'dd if=/dev/zero of=/media/usb/swapfile bs=1024 count=524288'
- cmd2 = 'mkswap /media/usb/swapfile'
- cmd3 = 'swapon /media/usb/swapfile'
- cmd4 = 'echo "/media/usb/swapfile swap swap defaults 0 0 " >> /etc/fstab'
- cmd5 = 'echo "/sbin/swapon /usb/swapfile; swapon -a " > /etc/init.d/rcS.local'
- cmd6 = 'chmod 755 /etc/init.d/rcS.local; chmod 755 /media/usb/swapfile; /sbin/swapon /usb/swapfile'
- cmd7 = "echo -e '\n\n%s '" % _('Creation complete swap 512MB')
- self.session.open(Console, _('NeoBoot....'), [cmd0,
- cmd1,
- cmd2,
- cmd3,
- cmd4,
- cmd5,
- cmd6,
- cmd7])
- else:
- self.myClose(_('The file swapfile already exists!'))
+ if not os.path.exists('/media/hdd/swapfile') and not os.path.exists('/media/usb/swapfile') and not os.path.exists('/swapfile'):
+ self.goCreateSwap()
else:
- self.myClose(_('The folder hdd or usb not exists!'))
+ self.myClose(_('The file swapfile already exists.'))
+
+ def goCreateSwap(self):
+ supported_filesystems = frozenset(('ext4', 'ext3', 'ext2', 'vfat'))
+ candidates = []
+ mounts = getProcMounts()
+ for partition in harddiskmanager.getMountedPartitions(False, mounts):
+ if partition.filesystem(mounts) in supported_filesystems:
+ candidates.append((partition.description, partition.mountpoint))
+ if len(candidates):
+ self.session.openWithCallback(self.doCSplace, ChoiceBox, title=_('Please select device to use as swapfile location'), list=candidates)
+ else:
+ self.session.open(MessageBox, _("Sorry, no physical devices that supports SWAP attached. Can't create Swapfile on network or fat32 filesystems"), MessageBox.TYPE_INFO, timeout=10)
+ def doCSplace(self, name):
+ if name:
+ self.new_place = name[1]
+ myoptions = [[_('8 MB'), '8192'],
+ [_('16 MB'), '16384'],
+ [_('32 MB'), '32768'],
+ [_('64 MB'), '65536'],
+ [_('96 MB'), '98304'],
+ [_('128 MB'), '131072'],
+ [_('256 MB'), '262144'],
+ [_('512 MB'), '524288'],
+ [_('1024 MB'), '1048576']]
+ self.session.openWithCallback(self.doChoiceSize, ChoiceBox, title=_('Select the Swap File Size:'), list=myoptions)
+
+ def doChoiceSize(self, swapsize):
+ if swapsize:
+ self['actions'].setEnabled(False)
+ swapsize = swapsize[1]
+ myfile = self.new_place + '/swapfile'
+ cmd0 = "echo -e '\n\n%s '" % _('Creation swap ' + myfile + ', please wait...')
+ cmd1 = 'dd if=/dev/zero of=' + myfile + ' bs=1024 count=' + swapsize + ' 2>/dev/null'
+ cmd2 = 'mkswap ' + myfile
+ cmd3 = 'echo "'+ myfile + ' swap swap defaults 0 0" >> /etc/fstab'
+ cmd4 = 'chmod 755 ' + myfile + '; /sbin/swapon ' + myfile + ''
+ cmd5 = "echo -e '\n\n%s '" % _('Creation complete swap ' + swapsize + '')
+ self.session.open(Console, _('NeoBoot....'), [cmd0,
+ cmd1,
+ cmd2,
+ cmd3,
+ cmd4,
+ cmd5])
+ self.close()
+
+ def RemoveSwap(self):
+ if os.path.exists('/media/hdd/swapfile') or os.path.exists('/media/usb/swapfile') or os.path.exists('/swapfile'):
+ cmd0 = "echo -e '\n%s '" % _('Remove swap, please wait...')
+ if os.path.exists('/media/hdd/swapfile'):
+ system('/sbin/swapoff -a; sleep 2; rm -rf /media/hdd/swapfile; sleep 2')
+ if os.path.exists('/media/usb/swapfile'):
+ system('/sbin/swapoff -a; sleep 2; rm -rf /media/usb/swapfile; sleep 2')
+ if os.path.exists('/swapfile'):
+ system('/sbin/swapoff -a; sleep 2; rm -rf /swapfile; sleep 2')
+ with open('/etc/fstab', 'r') as f:
+ lines = f.read()
+ f.close()
+ fail = '/etc/fstab'
+ f = open(fail, 'r')
+ content = f.read()
+ f.close()
+ localfile2 = '/etc/fstab'
+ temp_file2 = open(localfile2, 'w')
+ if lines.find('/media/hdd/swapfile swap swap defaults 0 0') != -1:
+ temp_file2.write(content.replace("/media/hdd/swapfile swap swap defaults 0 0",""))
+ elif lines.find('/media/hdd//swapfile swap swap defaults 0 0') != -1:
+ temp_file2.write(content.replace("/media/hdd//swapfile swap swap defaults 0 0",""))
+ elif lines.find('/media/usb/swapfile swap swap defaults 0 0') != -1:
+ temp_file2.write(content.replace("/media/usb/swapfile swap swap defaults 0 0",""))
+ elif lines.find('/media/usb//swapfile swap swap defaults 0 0') != -1:
+ temp_file2.write(content.replace("/media/usb//swapfile swap swap defaults 0 0",""))
+ elif lines.find('//swapfile swap swap defaults 0 0') != -1:
+ temp_file2.write(content.replace("/swapfile swap swap defaults 0 0",""))
+ elif lines.find('/swapfile swap swap defaults 0 0') != -1:
+ temp_file2.write(content.replace("/swapfile swap swap defaults 0 0",""))
+ temp_file2.close()
+ cmd1 = "echo -e '\n\n%s '" % _('Swap file has been deleted.')
+ self.session.open(Console, _('NeoBoot....'), [cmd0,
+ cmd1])
+ self.close()
+ else:
+ self.myClose(_('The swap not exists.'))
+
def myClose(self, message):
self.session.open(MessageBox, message, MessageBox.TYPE_INFO)
self.close()