rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
desktop=self.get_desktop_patch() | desktop=self.get_desktop_path() | def cdrom_usb(self, *args): data=args[0] if isinstance(data, tuple): data=args[0][0] print_debug("cdrom_usb() data=%s" %data) if data.has_key('DEVPATH'): device="/dev/"+data["DEVPATH"].split('/')[2] else: device=data['DEVNAME'] action=data['ACTION'] devid=device.split('/')[2] remote_mnt="/mnt/%s" %(devid) |
return self.main.ingroup_tcos | if self.main.ingroup_tcos: return self.main.ingroup_tcos if not user: user=self.get_username() sgroups=grp.getgrall() if user == "root": return True for (sgroup, spass, sid, susers) in sgroups: if sgroup == group and user in susers: print_debug("user %s is in group %s"%(user, sgroup)) return True return False | def user_in_group(self, user=None, group=None): #tcos.libs.conf.debug_enabled=True |
self.main.xmlrpc.DBus("sendfiles", _("Teacher"), server, open ) | self.main.xmlrpc.DBus("sendfiles", "%s %s %s" %(_("Teacher"), server, open) ) | def send_external(self, filenames): if self.main.classview.ismultiple(): if not self.get_all_clients(): return elif not self.get_client(): return # action sent by vidal_joshur at gva dot es # send files # search for connected users if len(self.connected_users) == 0 or self.connected_users[0] == shared.NO_LOGIN_MSG: sha... |
self.main.xmlrpc.DBus("sendfiles", _("Teacher"), server, open ) | self.main.xmlrpc.DBus("sendfiles", "%s %s %s" %(_("Teacher"), server, open) ) | def send_one(self, widget, ip): if not self.get_client(): return # action sent by vidal_joshur at gva dot es # send files # search for connected users if len(self.connected_users) == 0 or self.connected_users[0] == shared.NO_LOGIN_MSG: shared.error_msg ( _("Can't send files, user is not logged") ) return str_scapes=["... |
self.main.xmlrpc.DBus("sendfiles", _("Teacher"), server, open ) | self.main.xmlrpc.DBus("sendfiles", "%s %s %s" %(_("Teacher"), server, open) ) | def send_all(self, *args): if not self.get_all_clients(): return # action sent by vidal_joshur at gva dot es # send files # search for connected users if len(self.connected_users) == 0 or self.connected_users[0] == shared.NO_LOGIN_MSG: shared.error_msg( _("No users logged.") ) return str_scapes=[" ", "(", ")", "*", "!... |
if ipstr.endswith(':0.0'): ipstr=ipstr.replace(':0.0', '') if ipstr.endswith(':0'): ipstr=ipstr.replace(':0', '') | if ipstr == "::1": return "127.0.0.1" if re.match("::([0-9]{1,9})$", ipstr): return "" if re.match(":([0-9]{1,9}|[0-9]{1,9}.[0-9]{1,9})$", ipstr): return "" if re.match(".*:([0-9]{1,9}|[0-9{1-9}].[0-9{1-9}])$", ipstr): ipstr=ipstr.rsplit(":", 1)[0] | def parseIPAddress(ipstr, return_ipv4=True): """ pass an string or binary IP and return IPV4 """ newip=[] isBin=False if ipstr.endswith(':0.0'): ipstr=ipstr.replace(':0.0', '') if ipstr.endswith(':0'): ipstr=ipstr.replace(':0', '') # hostname must start with letter and contain letters numbers and '-' or '.' if re.ma... |
ip=ipaddr.IPAddress(IPy.parseAddress("0x" + "".join(newip) )[0]) | try: ip=ipaddr.IPAddress(IPy.parseAddress("0x" + "".join(newip) )[0]) except: return ipstr | def parseIPAddress(ipstr, return_ipv4=True): """ pass an string or binary IP and return IPV4 """ newip=[] isBin=False if ipstr.endswith(':0.0'): ipstr=ipstr.replace(':0.0', '') if ipstr.endswith(':0'): ipstr=ipstr.replace(':0', '') # hostname must start with letter and contain letters numbers and '-' or '.' if re.ma... |
except Exception: | except Exception, err: print_debug(" parseIPAddress() Exception, error=%s"%err) | def parseIPAddress(ipstr, return_ipv4=True): """ pass an string or binary IP and return IPV4 """ newip=[] isBin=False if ipstr.endswith(':0.0'): ipstr=ipstr.replace(':0.0', '') if ipstr.endswith(':0'): ipstr=ipstr.replace(':0', '') # hostname must start with letter and contain letters numbers and '-' or '.' if re.ma... |
print "Xlib '%s' => " % a, parseIPAddress(a) | print " Xlib '%s' => '%s'" %(a, parseIPAddress(a)) | def parseIPAddress(ipstr, return_ipv4=True): """ pass an string or binary IP and return IPV4 """ newip=[] isBin=False if ipstr.endswith(':0.0'): ipstr=ipstr.replace(':0.0', '') if ipstr.endswith(':0'): ipstr=ipstr.replace(':0', '') # hostname must start with letter and contain letters numbers and '-' or '.' if re.ma... |
print "DISPLAY '192.168.0.10:0.0' => ", parseIPAddress('192.168.0.10:0.0') | print " DISPLAY '192.168.0.10:0.0' => '%s'" %parseIPAddress('192.168.0.10:0.0') print " DISPLAY 'thinkpad:0.0' => '%s'" %parseIPAddress('thinkpad:0.0') | def parseIPAddress(ipstr, return_ipv4=True): """ pass an string or binary IP and return IPV4 """ newip=[] isBin=False if ipstr.endswith(':0.0'): ipstr=ipstr.replace(':0.0', '') if ipstr.endswith(':0'): ipstr=ipstr.replace(':0', '') # hostname must start with letter and contain letters numbers and '-' or '.' if re.ma... |
print "NAME 'tcos10:0.0' => ", parseIPAddress('tcos10:0.0') | print " NAME 'tcos10:0.0' => '%s'" %parseIPAddress('tcos10:0.0') | def parseIPAddress(ipstr, return_ipv4=True): """ pass an string or binary IP and return IPV4 """ newip=[] isBin=False if ipstr.endswith(':0.0'): ipstr=ipstr.replace(':0.0', '') if ipstr.endswith(':0'): ipstr=ipstr.replace(':0', '') # hostname must start with letter and contain letters numbers and '-' or '.' if re.ma... |
print "XEPHYR NAME ':20.0' => ", parseIPAddress(':20.0') | print " XEPHYR NAME ':20.0' => '%s'" %parseIPAddress(':20.0') print " GDM change username '::2' => '%s'" %parseIPAddress('::2') print " Hostname 'tcos-01:0' => '%s'" %parseIPAddress('tcos-01:0') print " Hostname 'tcos.01:0' => '%s'" ... | def parseIPAddress(ipstr, return_ipv4=True): """ pass an string or binary IP and return IPV4 """ newip=[] isBin=False if ipstr.endswith(':0.0'): ipstr=ipstr.replace(':0.0', '') if ipstr.endswith(':0'): ipstr=ipstr.replace(':0', '') # hostname must start with letter and contain letters numbers and '-' or '.' if re.ma... |
self.cdrom( (('mount',data["DEVPATH"].split("/")[2]),) ) | if data['ACTION'] == "add": self.cdrom( ('mount', data["DEVPATH"].split("/")[2]), ) else: if data['ACTION'] == "mount": if self.xmlrpc.GetDevicesInfo(device=data["DEVPATH"], mode="--getstatus") == "1": return self.cdrom( (data['ACTION'], data["DEVPATH"].split("/")[2]), ) | def do_udev_event(self, *args): data=args[0] #print_debug ("do_udev_event() data=%s" %data) if data.has_key("ID_FS_TYPE") and data['ID_FS_TYPE'] == "iso9660": # newcdrom ADD (mount it) self.cdrom( (('mount',data["DEVPATH"].split("/")[2]),) ) if data.has_key("ID_BUS") and data["ID_BUS"] == "usb": if data.has_key("DEVPA... |
return None | return ipstr | def parseIPAddress(ipstr, return_ipv4=True): """ pass an string or binary IP and return IPV4 """ if ipstr.endswith(':0.0'): ipstr=ipstr.replace(':0.0', '') if ipstr.endswith(':0'): ipstr=ipstr.replace(':0', '') if re.match("[a-z]|[A-Z]", ipstr): print_debug( "parseIPAddress() NOT ip => %s"%ipstr ) return ipstr if ip... |
if return_ipv4 and ip.version == 6: | if return_ipv4 and ip.version == 6 and ip.ipv4_mapped: | def parseIPAddress(ipstr, return_ipv4=True): """ pass an string or binary IP and return IPV4 """ if ipstr.endswith(':0.0'): ipstr=ipstr.replace(':0.0', '') if ipstr.endswith(':0'): ipstr=ipstr.replace(':0', '') if re.match("[a-z]|[A-Z]", ipstr): print_debug( "parseIPAddress() NOT ip => %s"%ipstr ) return ipstr if ip... |
if groupexclude in ['exlude', True]: | print_debug("***thin-client***, isExclude(%s)=%s"%(data['ip'], groupexclude)) if groupexclude in ['exclude', True]: | def populate_hostlist(self, clients): print_debug ( "populate_hostlist() init" ) start1=time() # clean list print_debug ( "populate_hostlist() clear list and start progressbar!!!" ) self.main.common.threads_enter("TcosActions:populate_hostlist show progressbar") if tcosmonitor.shared.disable_textview_on_update and s... |
print "sys.argv[1]=%s => '%s'"%(sys.argv[1],parseIPAddress(sys.argv[1])) | value=parseIPAddress(sys.argv[1]) print >> sys.stderr, "shared.py sys.argv[1]='%s' => '%s'"%(sys.argv[1],value) print value | def parseIPAddress(ipstr, return_ipv4=True): """ pass an string or binary IP and return IPV4 """ newip=[] isBin=False if ipstr == "::1": # localhost in IPV6 return "127.0.0.1" # GDM when change username use a $DISPLAY like this "::12" if re.match("::([0-9]{1,9})$", ipstr): return "" # XEPHYR NAME ':20.0' if re.match... |
if tcosmonitor.shared.dont_show_users_in_group != None and data['username'] != "---" and data['username'] != None: | if tcosmonitor.shared.dont_show_users_in_group != None and not data['username'] in ["---", None]: | def populate_hostlist(self, clients): print_debug ( "populate_hostlist() init" ) start1=time() # clean list print_debug ( "populate_hostlist() clear list and start progressbar!!!" ) self.main.common.threads_enter("TcosActions:populate_hostlist show progressbar") if tcosmonitor.shared.disable_textview_on_update and s... |
if groupexclude: | if groupexclude in ['exlude', True]: | def populate_hostlist(self, clients): print_debug ( "populate_hostlist() init" ) start1=time() # clean list print_debug ( "populate_hostlist() clear list and start progressbar!!!" ) self.main.common.threads_enter("TcosActions:populate_hostlist show progressbar") if tcosmonitor.shared.disable_textview_on_update and s... |
if len(message[3][0]) == 1: | if " " in message[3][0]: | def new_message(self, message): print_debug ( "new_message() %s" %(message) ) |
b.ut_host = mitad1 | b.ut_host = half1 | def GetLast(self, ip, ingroup=None): start=time() last=None data={} if ip != "" and not self.ipValid(ip): ip=self.GetIpAddress(ip) hostname=self.GetHostname(ip) print_debug("GetLast() ip=%s hostname=%s "%(ip, hostname) ) for i in range(10): last_file=WTMP_FILE if i != 0: last_file=WTMP_FILE+".%d" %i if os.path.isfile(... |
if (os.access(path, os.X_OK)) and (not os.stat.isdir(path)): | if (os.access(path, os.X_OK)) and (not os.path.isdir(path)): | def is_executable(command): """Checks if a given command is available. Handy for dependency checks on external commands.""" for path in os.environ['PATH'].split(':'): path = os.path.join(path, command) if (os.access(path, os.X_OK)) and (not os.stat.isdir(path)): return True return False |
handle = open(boxfile, 'r') text = handle.readlines() handle.close() | handle = open(boxfile, 'r', encoding="utf8") | def parse_box(boxfile): """ Parse the tesseract positional information into a two dimensional array. [[char, x_min, y_min, x_max, y_max], ...] """ if not os.path.isfile(boxfile): print('err: ocr.parse_box(): File does not exist: "{0}"'.format(boxfile), file=sys.stderr) sys.exit(1) handle = open(boxfile, 'r') text = han... |
for line in text: | for line in handle: | def parse_box(boxfile): """ Parse the tesseract positional information into a two dimensional array. [[char, x_min, y_min, x_max, y_max], ...] """ if not os.path.isfile(boxfile): print('err: ocr.parse_box(): File does not exist: "{0}"'.format(boxfile), file=sys.stderr) sys.exit(1) handle = open(boxfile, 'r') text = han... |
pass | if (len(change['boxtext']) == len(change['text'])): pass else: pass | def resolve(self, boxdata, text): # Convert the boxing information into a plain text string with no bounding information. boxtext = '' for entry in boxdata: boxtext = boxtext + entry['char'] # Remove spacing and newlines from the readable text because the boxing data doesn't have those. text = text.replace(' ', '') tex... |
pass | print('case 02') index = boxdata.index(change['target']) new = {'char':'', 'xmin':0, 'ymin':0, 'xmax':0, 'ymax':0} new['char'] = change['text'] new['xmin'] = min([x['xmin'] for x in boxdata[index:index+len(change['boxtext'])]]) new['ymin'] = min([x['ymin'] for x in boxdata[index:index+len(change['boxtext'])]]) new['xma... | def resolve(self, boxdata, text): # Convert the boxing information into a plain text string with no bounding information. boxtext = '' for entry in boxdata: boxtext = boxtext + entry['char'] # Remove spacing and newlines from the readable text because the boxing data doesn't have those. text = text.replace(' ', '') tex... |
pass | print('case 03') index = boxdata.index(change['target']) del(boxdata[index]) i = 0 for char in list(change['text']): new = {'char':char, 'xmin':change['target']['xmin'], 'ymin':change['target']['ymin'], 'xmax':change['target']['xmax'], 'ymax':change['target']['ymax']} boxdata.insert(index+i, new) i = i + 1 | def resolve(self, boxdata, text): # Convert the boxing information into a plain text string with no bounding information. boxtext = '' for entry in boxdata: boxtext = boxtext + entry['char'] # Remove spacing and newlines from the readable text because the boxing data doesn't have those. text = text.replace(' ', '') tex... |
pass | print('case 04') index = boxdata.index(change['target']) for char in list(change['text']): boxdata[index]['char'] = char index = index + 1 | def resolve(self, boxdata, text): # Convert the boxing information into a plain text string with no bounding information. boxtext = '' for entry in boxdata: boxtext = boxtext + entry['char'] # Remove spacing and newlines from the readable text because the boxing data doesn't have those. text = text.replace(' ', '') tex... |
pass | print('case 07') index = boxdata.index(change['target']) i = 0 for char in list(change['text']): new = {'char':char, 'xmin':change['target']['xmin'], 'ymin':change['target']['ymin'], 'xmax':change['target']['xmax'], 'ymax':change['target']['ymax']} boxdata.insert(index+i, new) i = i + 1 | def resolve(self, boxdata, text): # Convert the boxing information into a plain text string with no bounding information. boxtext = '' for entry in boxdata: boxtext = boxtext + entry['char'] # Remove spacing and newlines from the readable text because the boxing data doesn't have those. text = text.replace(' ', '') tex... |
return | continue | def run(self): """Perform the main cleaning process which has these phases 1. General cleaning 2. Deep scan 3. Memory 4. Free disk space""" self.deepscans = {} # prioritize self.delayed_ops = [] for operation in self.operations: delayables = ['free_disk_space', 'memory'] for delayable in delayables: if operation not in... |
print 'debug: type(%s) = %s' % (pathname, type(pathname)) | def is_running(self): """Return whether the program is currently running""" for running in self.running: test = running[0] pathname = running[1] if 'exe' == test and 'posix' == os.name: if Unix.is_running(pathname): print "debug: process '%s' is running" % pathname return True elif 'exe' == test and 'nt' == os.name: pr... | |
options = [] | myoptions = [] | def get_whitelist_paths(self): """Return the whitelist of paths""" section = "whitelist/paths" if not self.config.has_section(section): return [] options = [] for option in sorted(self.config.options(section)): pos = option.find('_') if -1 == pos: continue options.append(option[0:pos]) values = [] for option in set(opt... |
options.append(option[0:pos]) | myoptions.append(option[0:pos]) | def get_whitelist_paths(self): """Return the whitelist of paths""" section = "whitelist/paths" if not self.config.has_section(section): return [] options = [] for option in sorted(self.config.options(section)): pos = option.find('_') if -1 == pos: continue options.append(option[0:pos]) values = [] for option in set(opt... |
for option in set(options): | for option in set(myoptions): | def get_whitelist_paths(self): """Return the whitelist of paths""" section = "whitelist/paths" if not self.config.has_section(section): return [] options = [] for option in sorted(self.config.options(section)): pos = option.find('_') if -1 == pos: continue options.append(option[0:pos]) values = [] for option in set(opt... |
if os.path.lexists(Common.autostart_path): FileUtilities.delete(Common.autostart_path) | if os.path.lexists(autostart_path): FileUtilities.delete(autostart_path) | def start_with_computer(enabled): """If enabled, create shortcut to start application with computer. If disabled, then delete the shortcut.""" if not enabled: if os.path.lexists(Common.autostart_path): FileUtilities.delete(Common.autostart_path) return if os.path.lexists(Common.autostart_path): return import shutil Gen... |
if os.path.lexists(Common.autostart_path): | if os.path.lexists(autostart_path): | def start_with_computer(enabled): """If enabled, create shortcut to start application with computer. If disabled, then delete the shortcut.""" if not enabled: if os.path.lexists(Common.autostart_path): FileUtilities.delete(Common.autostart_path) return if os.path.lexists(Common.autostart_path): return import shutil Gen... |
General.makedirs(os.path.dirname(Common.autostart_path)) shutil.copy(Common.launcher_path, Common.autostart_path) os.chmod(Common.autostart_path, 0755) | General.makedirs(os.path.dirname(autostart_path)) shutil.copy(launcher_path, autostart_path) os.chmod(autostart_path, 0755) | def start_with_computer(enabled): """If enabled, create shortcut to start application with computer. If disabled, then delete the shortcut.""" if not enabled: if os.path.lexists(Common.autostart_path): FileUtilities.delete(Common.autostart_path) return if os.path.lexists(Common.autostart_path): return import shutil Gen... |
General.chownself(Common.autostart_path) | General.chownself(autostart_path) | def start_with_computer(enabled): """If enabled, create shortcut to start application with computer. If disabled, then delete the shortcut.""" if not enabled: if os.path.lexists(Common.autostart_path): FileUtilities.delete(Common.autostart_path) return if os.path.lexists(Common.autostart_path): return import shutil Gen... |
return os.path.lexists(Common.autostart_path) | return os.path.lexists(autostart_path) | def start_with_computer_check(): """Return boolean whether BleachBit will start with the computer""" return os.path.lexists(Common.autostart_path) |
There is NO WARRANTY, to the extent permitted by law.""" % Common.APP_VERSION | There is NO WARRANTY, to the extent permitted by law.""" % APP_VERSION | def process_cmd_line(): """Parse the command line and execute given commands.""" # TRANSLATORS: This is the command line usage. Don't translate # %prog, but do translate usage, options, cleaner, and option. # More information about the command line is here # http://bleachbit.sourceforge.net/documentation/command-line ... |
(dir, file) = os.path.split(pathname1) | (head, tail) = os.path.split(pathname1) | def wipe_name(pathname1): """Wipe the original filename and return the new pathname""" (dir, file) = os.path.split(pathname1) # reference http://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits maxlen = 226 # first, rename to a long name i = 0 while True: try: pathname2 = os.path.join(dir, __random_string(maxlen... |
pathname2 = os.path.join(dir, __random_string(maxlen)) | pathname2 = os.path.join(head, __random_string(maxlen)) | def wipe_name(pathname1): """Wipe the original filename and return the new pathname""" (dir, file) = os.path.split(pathname1) # reference http://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits maxlen = 226 # first, rename to a long name i = 0 while True: try: pathname2 = os.path.join(dir, __random_string(maxlen... |
pathname3 = os.path.join(dir, __random_string(i + 1)) | pathname3 = os.path.join(head, __random_string(i + 1)) | def wipe_name(pathname1): """Wipe the original filename and return the new pathname""" (dir, file) = os.path.split(pathname1) # reference http://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits maxlen = 226 # first, rename to a long name i = 0 while True: try: pathname2 = os.path.join(dir, __random_string(maxlen... |
"debug: wipe_path('%s')" % pathname | print "debug: wipe_path('%s')" % pathname | def estimate_completion(): """Return (percent, seconds) to complete""" remaining_bytes = free_space(pathname) done_bytes = start_free_bytes - remaining_bytes if done_bytes < 0: # mayber user deleted large file after starting wipe done_bytes = 0 if 0 == start_free_bytes: done_percent = 0 else: done_percent = 1.0 * done_... |
buffer = libc.malloc(allocbytes) if 0 == buffer: print 'debug: malloc() returned', buffer | mbuffer = libc.malloc(allocbytes) if 0 == mbuffer: print 'debug: malloc() returned', mbuffer | def fill_helper(): report_free() allocbytes = int(physical_free() * 0.75) if allocbytes < 1024: return megabytes = allocbytes / (1024**2) print "info: allocating %.2f MB (%d B) memory" % (megabytes, allocbytes) buffer = libc.malloc(allocbytes) if 0 == buffer: print 'debug: malloc() returned', buffer return print "debug... |
libc.memset(buffer, 0x00, allocbytes) | libc.memset(mbuffer, 0x00, allocbytes) | def fill_helper(): report_free() allocbytes = int(physical_free() * 0.75) if allocbytes < 1024: return megabytes = allocbytes / (1024**2) print "info: allocating %.2f MB (%d B) memory" % (megabytes, allocbytes) buffer = libc.malloc(allocbytes) if 0 == buffer: print 'debug: malloc() returned', buffer return print "debug... |
libc.free(buffer) | libc.free(mbuffer) | def fill_helper(): report_free() allocbytes = int(physical_free() * 0.75) if allocbytes < 1024: return megabytes = allocbytes / (1024**2) print "info: allocating %.2f MB (%d B) memory" % (megabytes, allocbytes) buffer = libc.malloc(allocbytes) if 0 == buffer: print 'debug: malloc() returned', buffer return print "debug... |
bytes = physical_free() print "debug: physical free: %d B (%d MB)" % (bytes, bytes/1024**2) | bytes_free = physical_free() print "debug: physical free: %d B (%d MB)" % \ (bytes_free, bytes_free / 1024**2) | def report_free(): """Report free memory""" bytes = physical_free() print "debug: physical free: %d B (%d MB)" % (bytes, bytes/1024**2) |
datetime.datetime.now() - openfiles.last_scan_time, \ | time.time() - openfiles.last_scan_time, \ | def test_OpenFiles(self): """Unit test for class OpenFiles""" if 'nt' == os.name: return |
self.add_option('memory', _('Memory'), _('Wipe the swap and free memory')) | _('Wipe the swap and free memory')) | def __init__(self): Cleaner.__init__(self) if 'posix' == os.name: # TRANSLATORS: desktop entries are .desktop files in Linux tha # make up the application menu (the menu that shows BleachBit, # Firefox, and others. The .desktop files also associate file # types, so clicking on an .html file in Nautilus brings up # Fir... |
(status, hash) = self.__recognized(pathname) | (status, myhash) = self.__recognized(pathname) | def __scan(self): """Look for files and act accordingly""" changes = [] for pathname in sorted(list_cleanerml_files(local_only = True)): pathname = os.path.abspath(pathname) (status, hash) = self.__recognized(pathname) if NEW == status or CHANGED == status: changes.append([ pathname, status, hash ]) if len(changes) > 0... |
changes.append([ pathname, status, hash ]) | changes.append([ pathname, status, myhash ]) | def __scan(self): """Look for files and act accordingly""" changes = [] for pathname in sorted(list_cleanerml_files(local_only = True)): pathname = os.path.abspath(pathname) (status, hash) = self.__recognized(pathname) if NEW == status or CHANGED == status: changes.append([ pathname, status, hash ]) if len(changes) > 0... |
hash = change[2] | myhash = change[2] | def __scan(self): """Look for files and act accordingly""" changes = [] for pathname in sorted(list_cleanerml_files(local_only = True)): pathname = os.path.abspath(pathname) (status, hash) = self.__recognized(pathname) if NEW == status or CHANGED == status: changes.append([ pathname, status, hash ]) if len(changes) > 0... |
if backends.has_key('_gui'): del backends['_gui'] | def worker_done(self, worker, really_delete): """Callback for when Worker is done""" self.progressbar.set_text("") self.progressbar.set_fraction(1) self.progressbar.set_text(_("Done.")) self.textview.scroll_mark_onscreen(self.textbuffer.get_insert()) self.set_sensitive(True) | |
options.set('shred', True, commit = False) | def cb_shred_file(self, action): """Callback for shredding a file or folder""" | |
options.restore() | def cb_shred_file(self, action): """Callback for shredding a file or folder""" | |
buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_DELETE, gtk.RESPONSE_OK)) | buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) | def browse_file(parent, title): """Prompt user to select a single file""" # FIXME: add native Windows dialog chooser = gtk.FileChooserDialog(title = title, parent = parent, action = gtk.FILE_CHOOSER_ACTION_OPEN, buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_DELETE, gtk.RESPONSE_OK)) chooser.set_current_... |
self.add_option('dom', _('DOM Storage'), _('Delete HTML5 cookies') | self.add_option('dom', _('DOM Storage'), _('Delete HTML5 cookies')) | def __init__(self): Cleaner.__init__(self) self.add_option('cache', _('Cache'), _('Delete the web cache, which reduces time to display revisited pages')) self.add_option('cookies', _('Cookies'), _('Delete cookies, which contain information such as web site preferences, authentication, and tracking identification')) # T... |
"""1. General cleaning""" """2. Deep scan""" """3. Memory""" """4. Free disk space""" | def run(self): """Perform the main cleaning process which has these phases""" """1. General cleaning""" """2. Deep scan""" """3. Memory""" """4. Free disk space""" self.deepscans = {} # prioritize self.delayed_ops = [] for operation in self.operations: delayables = ['free_disk_space', 'memory'] for delayable in delayab... | |
output = General.run_external(args, stdout = stdout_, env = env) | output = run_external(args, stdout = stdout_, env = env) | def _test_preview(self, args, stdout = None, env = None): """Helper to test preview""" # Use devnull because in some cases the buffer will be too large, # and the other alternative, the screen, is not desirable. if stdout: stdout_ = None else: stdout_ = open(os.devnull, 'w') output = General.run_external(args, stdout =... |
output = General.run_external(args) | output = run_external(args) | def test_invalid_locale(self): """Unit test for invalid locales""" os.environ['LANG'] = 'blahfoo' # tests are run from the parent directory path = os.path.join('bleachbit', 'CLI.py') args = [sys.executable, path, '--version'] output = General.run_external(args) self.assertNotEqual(output[1].find('Copyright'), -1, str(o... |
dir = tempfile.mkdtemp(suffix = "0" * 200) self.assert_(os.path.exists(dir)) dir2 = tempfile.mkdtemp(suffix = "0" * 200, dir = dir) (handle, filename) = tempfile.mkstemp(dir = dir2, suffix = "1" * 200) | if 'posix' == os.name: dir0len = 210 dir1len = 10 filelen = 210 if 'nt' == os.name: dir0len = 100 dir1len = 5 filelen = 5 dir0 = tempfile.mkdtemp(suffix = "0" * dir0len) self.assert_(os.path.exists(dir0)) dir1 = tempfile.mkdtemp(suffix = "1" * dir1len, dir = dir0) self.assert_(os.path.exists(dir1)) (handle, filena... | def test_wipe_name(self): """Unit test for wipe_name()""" |
self.assert_(os.path.exists(dir2)) | self.assert_(os.path.exists(dir0)) self.assert_(os.path.exists(dir1)) | def test_wipe_name(self): """Unit test for wipe_name()""" |
dir2new = wipe_name(dir2) self.assert_(len(dir2) > len(dir2new)) self.assert_(not os.path.exists(dir2)) self.assert_(os.path.exists(dir2new)) os.rmdir(dir2new) | dir1new = wipe_name(dir1) self.assert_(len(dir1) > len(dir1new)) self.assert_(not os.path.exists(dir1)) self.assert_(os.path.exists(dir1new)) os.rmdir(dir1new) | def test_wipe_name(self): """Unit test for wipe_name()""" |
os.rmdir(dir) self.assert_(not os.path.exists(dir)) | os.rmdir(dir0) self.assert_(not os.path.exists(dir0)) | def test_wipe_name(self): """Unit test for wipe_name()""" |
def __random_string(len): return ''.join(random.choice(string.ascii_letters + '0123456789 _.-') for i in xrange(len)) | def __random_string(length): """Return random alphanumeric characters of given length""" return ''.join(random.choice(string.ascii_letters + '0123456789 _.-') \ for i in xrange(length)) | def __random_string(len): return ''.join(random.choice(string.ascii_letters + '0123456789 _.-') for i in xrange(len)) |
def human_to_bytes(string, format = 'si'): | def human_to_bytes(human, hformat = 'si'): | def human_to_bytes(string, format = 'si'): """Convert a string like 10.2GB into bytes. By default use SI standard (base 10). The format of the GNU command 'du' (base 2) also supported.""" if 'si' == format: multiplier = { 'B' : 1, 'kB': 1000, 'MB': 1000**2, \ 'GB': 1000**3, 'TB': 1000**4 } matches = re.findall("^([0-... |
if 'si' == format: | if 'si' == hformat: | def human_to_bytes(string, format = 'si'): """Convert a string like 10.2GB into bytes. By default use SI standard (base 10). The format of the GNU command 'du' (base 2) also supported.""" if 'si' == format: multiplier = { 'B' : 1, 'kB': 1000, 'MB': 1000**2, \ 'GB': 1000**3, 'TB': 1000**4 } matches = re.findall("^([0-... |
matches = re.findall("^([0-9]*)(\.[0-9]{1,2})?([kMGT]{0,1}B)$", string) elif 'du' == format: | matches = re.findall("^([0-9]*)(\.[0-9]{1,2})?([kMGT]{0,1}B)$", human) elif 'du' == hformat: | def human_to_bytes(string, format = 'si'): """Convert a string like 10.2GB into bytes. By default use SI standard (base 10). The format of the GNU command 'du' (base 2) also supported.""" if 'si' == format: multiplier = { 'B' : 1, 'kB': 1000, 'MB': 1000**2, \ 'GB': 1000**3, 'TB': 1000**4 } matches = re.findall("^([0-... |
matches = re.findall("^([0-9]*)(\.[0-9]{1,2})?([KMGT]{0,1}B)$", string) | matches = re.findall("^([0-9]*)(\.[0-9]{1,2})?([KMGT]{0,1}B)$", human) | def human_to_bytes(string, format = 'si'): """Convert a string like 10.2GB into bytes. By default use SI standard (base 10). The format of the GNU command 'du' (base 2) also supported.""" if 'si' == format: multiplier = { 'B' : 1, 'kB': 1000, 'MB': 1000**2, \ 'GB': 1000**3, 'TB': 1000**4 } matches = re.findall("^([0-... |
raise ValueError("Invalid format: '%s'" % format) | raise ValueError("Invalid format: '%s'" % hformat) | def human_to_bytes(string, format = 'si'): """Convert a string like 10.2GB into bytes. By default use SI standard (base 10). The format of the GNU command 'du' (base 2) also supported.""" if 'si' == format: multiplier = { 'B' : 1, 'kB': 1000, 'MB': 1000**2, \ 'GB': 1000**3, 'TB': 1000**4 } matches = re.findall("^([0-... |
raise ValueError("Invalid input for '%s' (format='%s')" % (string, format)) | raise ValueError("Invalid input for '%s' (hformat='%s')" % (human, hformat)) | def human_to_bytes(string, format = 'si'): """Convert a string like 10.2GB into bytes. By default use SI standard (base 10). The format of the GNU command 'du' (base 2) also supported.""" if 'si' == format: multiplier = { 'B' : 1, 'kB': 1000, 'MB': 1000**2, \ 'GB': 1000**3, 'TB': 1000**4 } matches = re.findall("^([0-... |
delpath = os.remove(wipe_name(path)) | delpath = wipe_name(path) | def delete(path, shred = False): """Delete path that is either file, directory, link or FIFO""" try: print u"info: removing '%s'" % path except: p = re.compile('[\x7f-\xff]') print r"info: removing '%s'" % p.sub('?', path) is_special = False if 'posix' == os.name: # With certain (relatively rare) files on Windows os.ls... |
files += file | files += [ file ] | def get_commands(self, option_id): # cache if 'posix' == os.name and 'cache' == option_id: dirname = os.path.expanduser("~/.cache/") for filename in children_in_directory(dirname, True): yield Command.Delete(filename) |
cleaner.name = '' | cleaner.name = _("System") | def create_simple_cleaner(paths): cleaner = Cleaner() cleaner.add_option(option_id = 'files', name = '', description = '') cleaner.name = '' import Action class CustomFileAction(Action.ActionProvider): action_key = '__customfileaction' def get_commands(self): for path in paths: if os.path.isdir(path): for child in chil... |
def message_dialog(parent, msg, type = gtk.MESSAGE_ERROR, buttons = gtk.BUTTONS_OK): | def message_dialog(parent, msg, mtype = gtk.MESSAGE_ERROR, buttons = gtk.BUTTONS_OK): | def message_dialog(parent, msg, type = gtk.MESSAGE_ERROR, buttons = gtk.BUTTONS_OK): """Convenience wrapper for gtk.MessageDialog""" dialog = gtk.MessageDialog(parent, \ gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, \ type, \ buttons, \ msg) resp = dialog.run() dialog.destroy() return resp |
type, \ | mtype, \ | def message_dialog(parent, msg, type = gtk.MESSAGE_ERROR, buttons = gtk.BUTTONS_OK): """Convenience wrapper for gtk.MessageDialog""" dialog = gtk.MessageDialog(parent, \ gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, \ type, \ buttons, \ msg) resp = dialog.run() dialog.destroy() return resp |
globexs += ( ('/usr/share/aptitude/aptitude-defaults.[a-z]{2}(_[A-Z])?', 'defaults.([a-z]{2})'), ) | globexs += ( ('/usr/share/aptitude/aptitude-defaults*', '-defaults.([a-z]{2})'), ) | def localization_paths(self, language_filter): """Return paths containing localization files""" |
self.config = ConfigParser.SafeConfigParser() | def __init__(self): self.restore() self.config = ConfigParser.SafeConfigParser() | |
try: os.rmdir(options_dir) except: print traceback.print_exc() err = str(sys.exc_info()[1]) self.append_text(err, 'error') while gtk.events_pending(): gtk.main_iteration() time.sleep(3) | if not portable_mode: try: os.rmdir(options_dir) except: print traceback.print_exc() err = str(sys.exc_info()[1]) self.append_text(err, 'error') while gtk.events_pending(): gtk.main_iteration() time.sleep(3) | def cb_shred_quit(self, action): """Shred settings (for privacy reasons) and quit""" try: FileUtilities.delete(options_file, shred = True) if portable_mode: open(options_file, 'w').write('[Portable]\n') fn = os.path.join(options_dir, "deepscan.sqlite3") if os.path.exists(fn): FileUtilities.delete(fn, shred = True) exce... |
for paths in pathnames: type_code = paths[0] type_str = None if type_code == 'file': type_str = _('File') elif type_code == 'folder': type_str = _('Folder') else: raise RuntimeError("Invalid type code: '%s'" % type_code) path = paths[1] liststore.append( [ type_str, path ] ) | if None != pathnames: for paths in pathnames: type_code = paths[0] type_str = None if type_code == 'file': type_str = _('File') elif type_code == 'folder': type_str = _('Folder') else: raise RuntimeError("Invalid type code: '%s'" % type_code) path = paths[1] liststore.append( [ type_str, path ] ) | def remove_whitelist_path_cb(button): """Callback for removing a path""" treeselection = treeview.get_selection() (model, _iter) = treeselection.get_selected() if None == _iter: # nothing selected return pathname = model[_iter][1] liststore.remove(_iter) for this_pathname in pathnames: if this_pathname[1] == pathname: ... |
if Common.online_update_notification_enabled: | if online_update_notification_enabled: | def __general_page(self): """Return a widget containing the general page""" |
import Unix | def preserve_toggled_cb(cell, path, liststore): """Callback for toggling the 'preserve' column""" __iter = liststore.get_iter_from_string(path) value = not liststore.get_value(__iter, 0) liststore.set(__iter, 0, value) langid = liststore[path][1] options.set_language(langid, value) | |
return Windows.browse_folder(parent.window.handle, title) | ret = Windows.browse_folder(parent.window.handle, title) return [ret] if multiple else ret | def browse_folder(parent, title, multiple, delete): """Ask the user to select a folder. Return the full path or None.""" if 'nt' == os.name: return Windows.browse_folder(parent.window.handle, title) # fall back to GTK+ if delete: stock_button = gtk.STOCK_DELETE else: stock_button = gtk.STOCK_ADD chooser = gtk.FileCh... |
print 'debug: type(%s) = %s' % (p, type(p)) | def is_running(self): """Return whether the program is currently running""" for running in self.running: test = running[0] pathname = running[1] if 'exe' == test and 'posix' == os.name: if Unix.is_running(pathname): print "debug: process '%s' is running" % pathname return True elif 'exe' == test and 'nt' == os.name: fo... | |
def run_deep_scan(): | def run_deep_scan(self): | def run_deep_scan(): """Run deep scans""" print 'debug: deepscans=', self.deepscans # TRANSLATORS: The "deep scan" feature searches over broad # areas of the file system such as the user's whole home directory # or all the system executables. self.ui.update_progress_bar(_("Please wait. Running deep scan.")) yield True... |
self.assertEqual(w.total_special, 3) self.assertEqual(w.total_errors, 2) | self.assertEqual(worker.total_special, 3) self.assertEqual(worker.total_errors, 2) | def test_TestActionProvider(self): """Test Worker using Action.TestActionProvider""" ui = CLI.CliCallback() (fd, filename) = tempfile.mkstemp('bleachbit-test') os.write(fd, '123') os.close(fd) self.assert_(os.path.exists(filename)) astr = '<action command="test" path="%s"/>' % filename cleaner = TestCleaner.action_to_c... |
self.assertEqual(w.total_bytes, 4096+10+10) self.assertEqual(w.total_deleted, 3) | self.assertEqual(worker.total_bytes, 4096+10+10) self.assertEqual(worker.total_deleted, 3) | def test_TestActionProvider(self): """Test Worker using Action.TestActionProvider""" ui = CLI.CliCallback() (fd, filename) = tempfile.mkstemp('bleachbit-test') os.write(fd, '123') os.close(fd) self.assert_(os.path.exists(filename)) astr = '<action command="test" path="%s"/>' % filename cleaner = TestCleaner.action_to_c... |
self.assertEqual(w.total_bytes, 3+3+10+10) self.assertEqual(w.total_deleted, 4) | self.assertEqual(worker.total_bytes, 3+3+10+10) self.assertEqual(worker.total_deleted, 4) | def test_TestActionProvider(self): """Test Worker using Action.TestActionProvider""" ui = CLI.CliCallback() (fd, filename) = tempfile.mkstemp('bleachbit-test') os.write(fd, '123') os.close(fd) self.assert_(os.path.exists(filename)) astr = '<action command="test" path="%s"/>' % filename cleaner = TestCleaner.action_to_c... |
self.assertEqual(w.total_special, 0) self.assertEqual(w.total_errors, 0) self.assertEqual(w.total_deleted, 2) | self.assertEqual(worker.total_special, 0) self.assertEqual(worker.total_errors, 0) self.assertEqual(worker.total_deleted, 2) | def test_multiple_options(self): """Test one cleaner with two options""" ui = CLI.CliCallback() (fd, filename1) = tempfile.mkstemp('bleachbit-test') os.close(fd) self.assert_(os.path.exists(filename1)) (fd, filename2) = tempfile.mkstemp('bleachbit-test') os.close(fd) self.assert_(os.path.exists(filename2)) |
print "info: removing '%s'" % path.encode('ascii', 'replace') | p = re.compile('[\x7f-\xff]') print r"info: removing '%s'" % p.sub('?', path) | def delete(path, shred = False): """Delete path that is either file, directory, link or FIFO""" try: print u"info: removing '%s'" % path except: # FIXME: unicode exception workaround for Windows (see unit test) print "info: removing '%s'" % path.encode('ascii', 'replace') mode = os.lstat(path)[stat.ST_MODE] if stat.S_I... |
self.last_scan_time = datetime.datetime.now() | self.last_scan_time = time.time() | def scan(self): """Update cache""" self.last_scan_time = datetime.datetime.now() self.files = [] for filename in glob.iglob("/proc/*/fd/*"): try: target = os.path.realpath(filename) except TypeError: # happens, for example, when link points to # '/etc/password\x00 (deleted)' continue if self.file_qualifies(target): sel... |
if None == self.last_scan_time or (datetime.datetime.now() - self.last_scan_time).seconds > 10: | if None == self.last_scan_time or (time.time() - self.last_scan_time) > 10: | def is_open(self, filename): """Return boolean whether filename is open by running process""" if None == self.last_scan_time or (datetime.datetime.now() - self.last_scan_time).seconds > 10: self.scan() return filename in self.files |
last_idle = datetime.datetime.now() | last_idle = last_idle = time.time() | def temporaryfile(): # reference http://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits maxlen = 245 f = None i = 0 while True: try: f = tempfile.TemporaryFile(dir = pathname, suffix = __random_string(maxlen)) break except OSError, e: if e.errno == 36: # OSError: [Errno 36] File name too long if maxlen > 10: ma... |
if idle and (last_idle - datetime.datetime.now()).seconds > 1: | if idle and (time.time() - last_idle) > 2: | def temporaryfile(): # reference http://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits maxlen = 245 f = None i = 0 while True: try: f = tempfile.TemporaryFile(dir = pathname, suffix = __random_string(maxlen)) break except OSError, e: if e.errno == 36: # OSError: [Errno 36] File name too long if maxlen > 10: ma... |
del backends['_gui'] | def cb_shred_file(self, action): """Callback for shredding a file or folder""" | |
dbpath = os.path.join(Common.options_dir, "deepscan.sqlite3") import sqlite3 self.conn = sqlite3.connect(dbpath) self.cursor = self.conn.cursor() try: self.cursor.execute("CREATE TABLE deepscan (path PRIMARY KEY, modified, size)") except sqlite3.OperationalError, e: if not str(e).strip() == "table deepscan already exis... | def __init__(self): dbpath = os.path.join(Common.options_dir, "deepscan.sqlite3") import sqlite3 self.conn = sqlite3.connect(dbpath) self.cursor = self.conn.cursor() try: self.cursor.execute("CREATE TABLE deepscan (path PRIMARY KEY, modified, size)") except sqlite3.OperationalError, e: if not str(e).strip() == "table d... | |
print 'debug: searches=', self.searches | print 'debug: DeepScan.scan: searches=', self.searches | def scan(self): """Perform requested searches and yield each match""" print 'debug: searches=', self.searches import time yield_time = time.time() |
if e.message.find('file is encrypted or is not a database') == -1: | if -1 == e.message.find('file is encrypted or is not a database') and \ -1 == e.message.find('or missing database'): | def execute(self, really_delete): |
cmds = "" | def delete_mozilla_url_history(path): """Delete URL history in Mozilla places.sqlite (Firefox 3 and family)""" # delete the URLs in moz_places places_suffix = "where id in (select " \ "moz_places.id from moz_places " \ "left join moz_inputhistory on moz_inputhistory.place_id = moz_places.id " \ "left join moz_bookmark... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.