Break the entire program with `Ctrl-C`.
sys.stderr.flush()
except KeyboardInterrupt:
- return 0
-
- # Tested
- return 1
+ return
def stop(self):
stop_subp(None) # Stop subprocess; do not log restarting
if error is not None:
bookmark.error = error
- return 1
+ return
if http_status_code and (http_status_code >= 300):
self.set_redirect(bookmark, http_status_code, redirect_to)
- return 1
+ return
size = 0
last_modified = None
except KeyboardInterrupt:
self.log("Keyboard interrupt (^C)")
- return 0
+ return
except socket.error as e:
bookmark.error = get_error(e)
finally:
self.finish_check_url(bookmark)
- # Tested
- return 1
-
def smart_get(self, bookmark, url, accept_charset=False):
split_results = urlsplit(url)
url_proto = split_results.scheme
print("Using", robot)
_robot = robot(None)
- if _robot.check_url(bookmark): # get real title and last modified date
- if title: # forced title
- bookmark.name = title
- elif hasattr(bookmark, "real_title"):
- bookmark.name = bookmark.real_title
- if report_stats:
- sys.stdout.write("Adding %s with title '%s'\n"
- % (href, bookmark.name))
- del bookmark.parent
- root_folder.append(bookmark)
-
- if report_stats:
- sys.stdout.write("Storing %s: " % storage.filename)
- sys.stdout.flush()
-
- storage.store(root_folder)
-
- if report_stats:
- print("Ok")
+ _robot.check_url(bookmark) # get real title and last modified date
+ if title: # forced title
+ bookmark.name = title
+ elif hasattr(bookmark, "real_title"):
+ bookmark.name = bookmark.real_title
+ if report_stats:
+ sys.stdout.write("Adding %s with title '%s'\n"
+ % (href, bookmark.name))
+ del bookmark.parent
+ root_folder.append(bookmark)
+
+ if report_stats:
+ sys.stdout.write("Storing %s: " % storage.filename)
+ sys.stdout.flush()
+
+ storage.store(root_folder)
+
+ if report_stats:
+ print("Ok")
if __name__ == '__main__':
bookmark = Bookmark(href=url, add_date=None)
bookmark.parent = None
- rcode = robot.check_url(bookmark)
- print("check_urls: %s" % rcode)
+ robot.check_url(bookmark)
if hasattr(bookmark, 'error'):
print(bookmark.error)
size = 0
checked = {}
- rcode = 1
for object_no in range(objects):
if show_pbar:
getattr(old_object, attr_name))
else:
log("Checking %s" % href)
- rcode = robot.check_url(object)
-
- if rcode:
- checked[href] = object_no
- urls_no = urls_no + 1
- try:
- size = size + int(object.size)
- except (AttributeError, TypeError, ValueError):
- pass # Some object does not have a size :(
- else:
- log("Interrupted by user (^C)")
- break
+ robot.check_url(object)
+
+ checked[href] = object_no
+ urls_no = urls_no + 1
+ try:
+ size = size + int(object.size)
+ except (AttributeError, TypeError, ValueError):
+ pass # Some object does not have a size :(
robot.stop()
if show_pbar:
del root_folder.linear
storage.store(root_folder)
- if rcode:
- log("check_urls_db finished ok")
+ log("check_urls_db finished ok")
log.close()