diff --git a/Tribler/Core/SessionConfig.py b/Tribler/Core/SessionConfig.py index 5fc2b072053..ad843c99473 100644 --- a/Tribler/Core/SessionConfig.py +++ b/Tribler/Core/SessionConfig.py @@ -31,13 +31,13 @@ class SessionConfigInterface: Use SessionStartupConfig from creating and manipulation configurations before session startup time. This is just a parent class. """ - def __init__(self,sessconfig=None): + def __init__(self, sessconfig=None): """ Constructor. @param sessconfig Optional dictionary used internally to make this a copy constructor. """ - if sessconfig is not None: # copy constructor + if sessconfig is not None: # copy constructor self.sessconfig = sessconfig return @@ -67,7 +67,7 @@ def __init__(self,sessconfig=None): - def set_state_dir(self,statedir): + def set_state_dir(self, statedir): """ Set the directory to store the Session's state in. @param statedir A preferably absolute path name. If the directory does not yet exist it will be created at Session create time. @@ -79,7 +79,19 @@ def get_state_dir(self): @return An absolute path name. """ return self.sessconfig['state_dir'] - def set_install_dir(self,installdir): + def set_dest_dir(self, destdir): + """ Set the directory to store the downloads to. + @param destdir A preferably absolute path name. If the directory + does not yet exist it will be created at Session create time. + """ + self.sessconfig['dest_dir'] = destdir + + def get_dest_dir(self): + """ Returns the directory to store downloads to. + @return An absolute path name. """ + return self.sessconfig['dest_dir'] + + def set_install_dir(self, installdir): """ Set the directory in which the Tribler Core software is installed. @param installdir An absolute path name """ @@ -91,7 +103,7 @@ def get_install_dir(self): return self.sessconfig['install_dir'] - def set_permid_keypair_filename(self,keypairfilename): + def set_permid_keypair_filename(self, keypairfilename): """ Set the filename containing the Elliptic Curve keypair to use for PermID-based authentication in this Session. @@ -108,7 +120,7 @@ def get_permid_keypair_filename(self): return self.sessconfig['eckeypairfilename'] - def set_listen_port(self,port): + def set_listen_port(self, port): """ Set the UDP and TCP listen port for this Session. @param port A port number. """ @@ -123,7 +135,7 @@ def get_listen_port(self): # # Advanced network settings # - def set_ip_for_tracker(self,value): + def set_ip_for_tracker(self, value): """ IP address to report to the tracker (default = set automatically). @param value An IP address as string. """ self.sessconfig['ip'] = value @@ -133,7 +145,7 @@ def get_ip_for_tracker(self): @return String """ return self.sessconfig['ip'] - def set_bind_to_addresses(self,value): + def set_bind_to_addresses(self, value): """ Set the list of IP addresses/hostnames to bind to locally. @param value A list of IP addresses as strings. """ self.sessconfig['bind'] = value @@ -143,7 +155,7 @@ def get_bind_to_addresses(self): @return list """ return self.sessconfig['bind'] - def set_upnp_mode(self,value): + def set_upnp_mode(self, value): """ Use to autoconfigure a UPnP router to forward the UDP/TCP listen port to this host:
@@ -161,7 +173,7 @@ def get_upnp_mode(self):
         @return UPNPMODE_* """
         return self.sessconfig['upnp_nat_access']
 
-    def set_autoclose_timeout(self,value):
+    def set_autoclose_timeout(self, value):
         """ Time to wait between closing sockets which nothing has been received
         on.
         @param value A number of seconds.
@@ -173,7 +185,7 @@ def get_autoclose_timeout(self):
         @return A number of seconds. """
         return self.sessconfig['timeout']
 
-    def set_autoclose_check_interval(self,value):
+    def set_autoclose_check_interval(self, value):
         """ Time to wait between checking if any connections have timed out.
         @param value A number of seconds.
         """
@@ -187,7 +199,7 @@ def get_autoclose_check_interval(self):
     #
     # Enable/disable Tribler features
     #
-    def set_megacache(self,value):
+    def set_megacache(self, value):
         """ Enable megacache databases to cache peers, torrent files and
         preferences (default = True).
         @param value Boolean. """
@@ -201,7 +213,7 @@ def get_megacache(self):
     #
     # Secure Overlay
     #
-    def set_overlay(self,value):
+    def set_overlay(self, value):
         """ Enable overlay swarm to enable Tribler's special features
         (default = True).
         @param value Boolean.
@@ -215,7 +227,7 @@ def get_overlay(self):
         @return Boolean. """
         return self.sessconfig['overlay']
 
-    def set_overlay_max_message_length(self,value):
+    def set_overlay_max_message_length(self, value):
         """ Maximal message length for messages sent over the secure overlay.
         @param value A number of bytes.
         """
@@ -230,7 +242,7 @@ def get_overlay_max_message_length(self):
     #
     # Buddycast
     #
-    def set_buddycast(self,value):
+    def set_buddycast(self, value):
         """ Enable buddycast recommendation system at startup (default = True)
         @param value Boolean.
         """
@@ -241,7 +253,7 @@ def get_buddycast(self):
         @return Boolean."""
         return self.sessconfig['buddycast']
 
-    def set_start_recommender(self,value):
+    def set_start_recommender(self, value):
         """ Buddycast can be temporarily disabled via this parameter
         (default = True). Must have been enabled at startup, see
         set_buddycast().
@@ -254,7 +266,7 @@ def get_start_recommender(self):
         @return Boolean."""
         return self.sessconfig['start_recommender']
 
-    def set_buddycast_interval(self,value):
+    def set_buddycast_interval(self, value):
         """ Number of seconds to pause between exchanging preference with a
         peer in Buddycast.
         @param value A number of seconds.
@@ -266,7 +278,7 @@ def get_buddycast_interval(self):
         @return A number of seconds. """
         return self.sessconfig['buddycast_interval']
 
-    def set_buddycast_collecting_solution(self,value):
+    def set_buddycast_collecting_solution(self, value):
         """ Set the Buddycast collecting solution. Only one policy implemented
         at the moment:
         
@@ -281,7 +293,7 @@ def get_buddycast_collecting_solution(self):
         @return BCOLPOLICY_* """
         return self.sessconfig['buddycast_collecting_solution']
 
-    def set_buddycast_max_peers(self,value):
+    def set_buddycast_max_peers(self, value):
         """ Set max number of peers to use for Buddycast recommendations """
         self.sessconfig['buddycast_max_peers'] = value
 
@@ -293,7 +305,7 @@ def get_buddycast_max_peers(self):
 
     # ProxyService_ parameters
     #
-    def set_proxyservice_dir(self,value):
+    def set_proxyservice_dir(self, value):
         """ Set the directory for storing state and content for proxyservice
         (default = Default destination dir (see get_default_dest_dir() +'proxyservice'.
         @param value An absolute path. """
@@ -304,7 +316,7 @@ def get_proxyservice_dir(self):
         @return An absolute path name. """
         return self.sessconfig['proxyservice_dir']
 
-    def set_proxyservice_status(self,value):
+    def set_proxyservice_status(self, value):
         """ Set the status of the proxyservice (on or off).
 
         ProxyService off means the current node could not be used as a proxy. ProxyService on means other nodes will be able to use it as a proxy.
@@ -328,7 +340,7 @@ def get_proxyservice_status(self):
     #
     # Torrent file collecting
     #
-    def set_torrent_collecting(self,value):
+    def set_torrent_collecting(self, value):
         """ Automatically collect torrents from peers in the network (default =
         True).
         @param value Boolean.
@@ -340,7 +352,7 @@ def get_torrent_collecting(self):
         @return Boolean. """
         return self.sessconfig['torrent_collecting']
 
-    def set_torrent_collecting_max_torrents(self,value):
+    def set_torrent_collecting_max_torrents(self, value):
         """ Set the maximum number of torrents to collect from other peers.
         @param value A number of torrents.
         """
@@ -351,7 +363,7 @@ def get_torrent_collecting_max_torrents(self):
         @return A number of torrents. """
         return self.sessconfig['torrent_collecting_max_torrents']
 
-    def set_torrent_collecting_dir(self,value):
+    def set_torrent_collecting_dir(self, value):
         """ Where to place collected torrents? (default is state_dir + 'collected_torrent_files')
         @param value An absolute path.
         """
@@ -362,7 +374,7 @@ def get_torrent_collecting_dir(self):
         @return An absolute path name. """
         return self.sessconfig['torrent_collecting_dir']
 
-    def set_torrent_collecting_rate(self,value):
+    def set_torrent_collecting_rate(self, value):
         """ Maximum download rate to use for torrent collecting.
         @param value A rate in KB/s. """
         self.sessconfig['torrent_collecting_rate'] = value
@@ -372,7 +384,7 @@ def get_torrent_collecting_rate(self):
         @return A rate in KB/s. """
         return self.sessconfig['torrent_collecting_rate']
 
-    def set_torrent_checking(self,value):
+    def set_torrent_checking(self, value):
         """ Whether to automatically check the health of collected torrents by
         contacting their trackers (default = True).
         @param value Boolean
@@ -384,7 +396,7 @@ def get_torrent_checking(self):
         @return Boolean. """
         return self.sessconfig['torrent_checking']
 
-    def set_torrent_checking_period(self,value):
+    def set_torrent_checking_period(self, value):
         """ Interval between automatic torrent health checks.
         @param value An interval in seconds.
         """
@@ -395,7 +407,7 @@ def get_torrent_checking_period(self):
         @return A number of seconds. """
         return self.sessconfig['torrent_checking_period']
 
-    def set_stop_collecting_threshold(self,value):
+    def set_stop_collecting_threshold(self, value):
         """ Stop collecting more torrents if the disk has less than this limit
         @param value A limit in MB.
         """
@@ -410,7 +422,7 @@ def get_stop_collecting_threshold(self):
     # The Tribler dialback mechanism is used to test whether a Session is
     # reachable from the outside and what its external IP address is.
     #
-    def set_dialback(self,value):
+    def set_dialback(self, value):
         """ Use other peers to determine external IP address (default = True)
         @param value Boolean
         """
@@ -425,7 +437,7 @@ def get_dialback(self):
     # Tribler's social networking feature transmits a nickname and picture
     # to all Tribler peers it meets.
     #
-    def set_social_networking(self,value):
+    def set_social_networking(self, value):
         """ Enable social networking. If enabled, a message containing the
         user's nickname and icon is sent to each Tribler peer met
         (default = True).
@@ -438,7 +450,7 @@ def get_social_networking(self):
         @return Boolean. """
         return self.sessconfig['socnet']
 
-    def set_nickname(self,value):
+    def set_nickname(self, value):
         """ The nickname you want to show to others.
         @param value A Unicode string.
         """
@@ -449,7 +461,7 @@ def get_nickname(self):
         @return A Unicode string. """
         return self.sessconfig['nickname']
 
-    def set_mugshot(self,value, mime = 'image/jpeg'):
+    def set_mugshot(self, value, mime='image/jpeg'):
         """ The picture of yourself you want to show to others.
         @param value A string of binary data of your image.
         @param mime A string of the mimetype of the data
@@ -464,7 +476,7 @@ def get_mugshot(self):
         else:
             return self.sessconfig['mugshot']
 
-    def set_peer_icon_path(self,value):
+    def set_peer_icon_path(self, value):
         """ Directory to store received peer icons (Default is statedir +
         STATEDIR_PEERICON_DIR).
         @param value An absolute path. """
@@ -479,7 +491,7 @@ def get_peer_icon_path(self):
     # Tribler remote query: ask other peers when looking for a torrent file
     # or peer
     #
-    def set_remote_query(self,value):
+    def set_remote_query(self, value):
         """ Enable queries from other peers. At the moment peers can ask
         whether this Session has collected or opened a torrent that matches
         a specified keyword query. (default = True)
@@ -494,7 +506,7 @@ def get_remote_query(self):
     #
     # BarterCast
     #
-    def set_bartercast(self,value):
+    def set_bartercast(self, value):
         """ Exchange upload/download statistics with peers (default = True)
         @param value Boolean
         """
@@ -509,7 +521,7 @@ def get_bartercast(self):
     #
     # For Tribler Video-On-Demand
     #
-    def set_video_analyser_path(self,value):
+    def set_video_analyser_path(self, value):
         """ Path to video analyser FFMPEG. The analyser is used to guess the
         bitrate of a video if that information is not present in the torrent
         definition. (default = look for it in $PATH)
@@ -520,13 +532,13 @@ def set_video_analyser_path(self,value):
     def get_video_analyser_path(self):
         """ Returns the path of the FFMPEG video analyser.
         @return An absolute path name. """
-        return self.sessconfig['videoanalyserpath'] # strings immutable
+        return self.sessconfig['videoanalyserpath']  # strings immutable
 
 
     #
     # Tribler's internal tracker
     #
-    def set_internal_tracker(self,value):
+    def set_internal_tracker(self, value):
         """ Enable internal tracker (default = True)
         @param value Boolean.
         """
@@ -537,7 +549,7 @@ def get_internal_tracker(self):
         @return Boolean. """
         return self.sessconfig['internaltracker']
 
-    def set_internal_tracker_url(self,value):
+    def set_internal_tracker_url(self, value):
         """ Set the internal tracker URL (default = determined dynamically
         from Session's IP+port)
         @param value URL.
@@ -551,7 +563,7 @@ def get_internal_tracker_url(self):
         return self.sessconfig['tracker_url']
 
 
-    def set_mainline_dht(self,value):
+    def set_mainline_dht(self, value):
         """ Enable mainline DHT support (default = True)
         @param value Boolean.
         """
@@ -566,7 +578,7 @@ def get_mainline_dht(self):
     #
     # Internal tracker access control settings
     #
-    def set_tracker_allowed_dir(self,value):
+    def set_tracker_allowed_dir(self, value):
         """ Only accept tracking requests for torrent in this dir (default is
         Session state-dir + STATEDIR_ITRACKER_DIR
         @param value An absolute path name.
@@ -578,7 +590,7 @@ def get_tracker_allowed_dir(self):
         @return An absolute path name. """
         return self.sessconfig['tracker_allowed_dir']
 
-    def set_tracker_allowed_list(self,value):
+    def set_tracker_allowed_list(self, value):
         """ Only allow peers to register for torrents that appear in the
         specified file. Cannot be used in combination with set_tracker_allowed_dir()
         @param value An absolute filename containing a list of torrent infohashes in hex format, one per
@@ -590,7 +602,7 @@ def get_tracker_allowed_list(self):
         @return An absolute path name. """
         return self.sessconfig['tracker_allowed_list']
 
-    def set_tracker_allowed_controls(self,value):
+    def set_tracker_allowed_controls(self, value):
         """ Allow special keys in torrents in the allowed_dir to affect tracker
         access.
         @param value Boolean
@@ -602,7 +614,7 @@ def get_tracker_allowed_controls(self):
         @return Boolean. """
         return self.sessconfig['tracker_allowed_controls']
 
-    def set_tracker_allowed_ips(self,value):
+    def set_tracker_allowed_ips(self, value):
         """ Only allow connections from IPs specified in the given file; file
         contains subnet data in the format: aa.bb.cc.dd/len.
         @param value An absolute path name.
@@ -614,7 +626,7 @@ def get_tracker_allowed_ips(self):
         @return An absolute path name."""
         return self.sessconfig['tracker_allowed_ips']
 
-    def set_tracker_banned_ips(self,value):
+    def set_tracker_banned_ips(self, value):
         """ Don't allow connections from IPs specified in the given file; file
         contains IP range data in the format: xxx:xxx:ip1-ip2
         @param value An absolute path name.
@@ -626,7 +638,7 @@ def get_tracker_banned_ips(self):
         @return An absolute path name. """
         return self.sessconfig['tracker_banned_ips']
 
-    def set_tracker_only_local_override_ip(self,value):
+    def set_tracker_only_local_override_ip(self, value):
         """ Ignore the 'ip' parameter in the GET announce from machines which
         aren't on local network IPs.
         
@@ -643,7 +655,7 @@ def get_tracker_only_local_override_ip(self):
         @return ITRACK_IGNORE_ANNOUNCEIP_* """
         return self.sessconfig['tracker_only_local_override_ip']
 
-    def set_tracker_parse_dir_interval(self,value):
+    def set_tracker_parse_dir_interval(self, value):
         """ Seconds between reloading of allowed_dir or allowed_file and
         allowed_ips and banned_ips lists.
         @param value A number of seconds.
@@ -656,7 +668,7 @@ def get_tracker_parse_dir_interval(self):
         @return A number of seconds. """
         return self.sessconfig['tracker_parse_dir_interval']
 
-    def set_tracker_scrape_allowed(self,value):
+    def set_tracker_scrape_allowed(self, value):
         """ Allow scrape access on the internal tracker (with a scrape request
         a BitTorrent client can retrieve information about how many peers are
         downloading the content.
@@ -674,7 +686,7 @@ def get_tracker_scrape_allowed(self):
         @return ITRACKSCRAPE_ALLOW_* """
         return self.sessconfig['tracker_scrape_allowed']
 
-    def set_tracker_allow_get(self,value):
+    def set_tracker_allow_get(self, value):
         """ Setting this parameter adds a /file?hash={hash} links to the
         overview page that the internal tracker makes available via HTTP
         at hostname:listenport. These links allow users to download the
@@ -693,7 +705,7 @@ def get_tracker_allow_get(self):
     #
     # Controls for internal tracker's output as Web server
     #
-    def set_tracker_favicon(self,value):
+    def set_tracker_favicon(self, value):
         """ File containing image/x-icon data to return when browser requests
         favicon.ico from the internal tracker. (Default = Tribler/Images/tribler.ico)
         @param value An absolute filename.
@@ -705,7 +717,7 @@ def get_tracker_favicon(self):
         @return An absolute path name. """
         return self.sessconfig['tracker_favicon']
 
-    def set_tracker_show_infopage(self,value):
+    def set_tracker_show_infopage(self, value):
         """ Whether to display an info page when the tracker's root dir is
         requested via HTTP.
         @param value Boolean
@@ -717,7 +729,7 @@ def get_tracker_show_infopage(self):
         @return Boolean. """
         return self.sessconfig['tracker_show_infopage']
 
-    def set_tracker_infopage_redirect(self,value):
+    def set_tracker_infopage_redirect(self, value):
         """ A URL to redirect the request for an info page to.
         @param value URL.
         """
@@ -728,7 +740,7 @@ def get_tracker_infopage_redirect(self):
         @return URL """
         return self.sessconfig['tracker_infopage_redirect']
 
-    def set_tracker_show_names(self,value):
+    def set_tracker_show_names(self, value):
         """ Whether to display names from the 'allowed dir'.
         @param value Boolean.
         """
@@ -739,7 +751,7 @@ def get_tracker_show_names(self):
         @return Boolean. """
         return self.sessconfig['tracker_show_names']
 
-    def set_tracker_keep_dead(self,value):
+    def set_tracker_keep_dead(self, value):
         """ Keep dead torrents after they expire (so they still show up on your
         /scrape and web page)
         @param value Boolean.
@@ -754,7 +766,7 @@ def get_tracker_keep_dead(self):
     #
     # Controls for internal tracker replies
     #
-    def set_tracker_reannounce_interval(self,value):
+    def set_tracker_reannounce_interval(self, value):
         """ Seconds downloaders should wait between reannouncing themselves
         to the internal tracker.
         @param value A number of seconds.
@@ -766,7 +778,7 @@ def get_tracker_reannounce_interval(self):
         @return A number of seconds. """
         return self.sessconfig['tracker_reannounce_interval']
 
-    def set_tracker_response_size(self,value):
+    def set_tracker_response_size(self, value):
         """ Number of peers to send to a peer in a reply to its announce
         at the internal tracker (i.e., in the info message)
         @param value A number of peers.
@@ -778,7 +790,7 @@ def get_tracker_response_size(self):
         @return A number of peers. """
         return self.sessconfig['tracker_response_size']
 
-    def set_tracker_nat_check(self,value):
+    def set_tracker_nat_check(self, value):
         """ How many times the internal tracker should attempt to check if a
         downloader is behind a  Network Address Translator (NAT) or firewall.
         If it is, the downloader won't be registered at the tracker, as other
@@ -796,7 +808,7 @@ def get_tracker_nat_check(self):
     #
     # Internal tracker persistence
     #
-    def set_tracker_dfile(self,value):
+    def set_tracker_dfile(self, value):
         """ File to store recent downloader info in (default = Session state
         dir + STATEDIR_ITRACKER_DIR + tracker.db
         @param value An absolute path name.
@@ -808,7 +820,7 @@ def get_tracker_dfile(self):
         @return An absolute path name. """
         return self.sessconfig['tracker_dfile']
 
-    def set_tracker_dfile_format(self,value):
+    def set_tracker_dfile_format(self, value):
         """ Format of the tracker database file. *_PICKLE is needed when Unicode
         filenames may appear in the tracker's state (=default).
         
@@ -824,7 +836,7 @@ def get_tracker_dfile_format(self):
         @return ITRACKDBFORMAT_* """
         return self.sessconfig['tracker_dfile_format']
 
-    def set_tracker_save_dfile_interval(self,value):
+    def set_tracker_save_dfile_interval(self, value):
         """ The interval between saving the internal tracker's state to
         the tracker database (see set_tracker_dfile()).
         @param value A number of seconds.
@@ -836,7 +848,7 @@ def get_tracker_save_dfile_interval(self):
         @return A number of seconds. """
         return self.sessconfig['tracker_save_dfile_interval']
 
-    def set_tracker_logfile(self,value):
+    def set_tracker_logfile(self, value):
         """ File to write the tracker logs to (default is NIL: or /dev/null).
         @param value A device name.
         """
@@ -847,7 +859,7 @@ def get_tracker_logfile(self):
         @return A device name. """
         return self.sessconfig['tracker_logfile']
 
-    def set_tracker_min_time_between_log_flushes(self,value):
+    def set_tracker_min_time_between_log_flushes(self, value):
         """ Minimum time between flushes of the tracker log.
         @param value A number of seconds.
         """
@@ -858,7 +870,7 @@ def get_tracker_min_time_between_log_flushes(self):
         @return A number of seconds. """
         return self.sessconfig['tracker_min_time_between_log_flushes']
 
-    def set_tracker_log_nat_checks(self,value):
+    def set_tracker_log_nat_checks(self, value):
         """ Whether to add entries to the tracker log for NAT-check results.
         @param value Boolean
         """
@@ -869,7 +881,7 @@ def get_tracker_log_nat_checks(self):
         @return Boolean. """
         return self.sessconfig['tracker_log_nat_checks']
 
-    def set_tracker_hupmonitor(self,value):
+    def set_tracker_hupmonitor(self, value):
         """ Whether to reopen the tracker log file upon receipt of a SIGHUP
         signal (Mac/UNIX only).
         @param value Boolean.
@@ -886,7 +898,7 @@ def get_tracker_hupmonitor(self):
     #
     # Esoteric tracker config parameters
     #
-    def set_tracker_socket_timeout(self,value):
+    def set_tracker_socket_timeout(self, value):
         """ Set timeout for closing connections to trackers.
         @param value A number of seconds.
         """
@@ -897,7 +909,7 @@ def get_tracker_socket_timeout(self):
         @return A number of seconds. """
         return self.sessconfig['tracker_socket_timeout']
 
-    def set_tracker_timeout_downloaders_interval(self,value):
+    def set_tracker_timeout_downloaders_interval(self, value):
         """ Interval between checks for expired downloaders, i.e., peers
         no longer in the swarm because they did not reannounce themselves.
         @param value A number of seconds.
@@ -909,7 +921,7 @@ def get_tracker_timeout_downloaders_interval(self):
         @return A number of seconds. """
         return self.sessconfig['tracker_timeout_downloaders_interval']
 
-    def set_tracker_timeout_check_interval(self,value):
+    def set_tracker_timeout_check_interval(self, value):
         """ Time to wait between checking if any connections to the internal
         tracker have timed out.
         @param value A number of seconds.
@@ -921,7 +933,7 @@ def get_tracker_timeout_check_interval(self):
         @return A number of seconds. """
         return self.sessconfig['tracker_timeout_check_interval']
 
-    def set_tracker_min_time_between_cache_refreshes(self,value):
+    def set_tracker_min_time_between_cache_refreshes(self, value):
         """ Minimum time before a cache is considered stale and is
         flushed.
         @param value A number of seconds.
@@ -937,7 +949,7 @@ def get_tracker_min_time_between_cache_refreshes(self):
     #
     # BitTornado's Multitracker feature
     #
-    def set_tracker_multitracker_enabled(self,value):
+    def set_tracker_multitracker_enabled(self, value):
         """ Whether to enable multitracker operation in which multiple
         trackers are used to register the peers for a specific torrent.
         @param value Boolean.
@@ -949,7 +961,7 @@ def get_tracker_multitracker_enabled(self):
         @return Boolean. """
         return self.sessconfig['tracker_multitracker_enabled']
 
-    def set_tracker_multitracker_allowed(self,value):
+    def set_tracker_multitracker_allowed(self, value):
         """ Whether to allow incoming tracker announces.
         
          * ITRACKMULTI_ALLOW_NONE: Don't allow.
@@ -965,7 +977,7 @@ def get_tracker_multitracker_allowed(self):
         @return ITRACKMULTI_ALLOW_* """
         return self.sessconfig['tracker_multitracker_allowed']
 
-    def set_tracker_multitracker_reannounce_interval(self,value):
+    def set_tracker_multitracker_reannounce_interval(self, value):
         """ Seconds between outgoing tracker announces to the other trackers in
         a multi-tracker setup.
         @param value A number of seconds.
@@ -977,7 +989,7 @@ def get_tracker_multitracker_reannounce_interval(self):
         @return A number of seconds. """
         return self.sessconfig['tracker_multitracker_reannounce_interval']
 
-    def set_tracker_multitracker_maxpeers(self,value):
+    def set_tracker_multitracker_maxpeers(self, value):
         """ Number of peers to retrieve from the other trackers in a tracker
          announce in a multi-tracker setup.
          @param value A number of peers.
@@ -989,7 +1001,7 @@ def get_tracker_multitracker_maxpeers(self):
         @return A number of peers. """
         return self.sessconfig['tracker_multitracker_maxpeers']
 
-    def set_tracker_aggregate_forward(self,value):
+    def set_tracker_aggregate_forward(self, value):
         """ Set an URL to which, if set, all non-multitracker requests are
         forwarded, with a password added (optional).
         @param value A 2-item list with format: [,|None]
@@ -1002,7 +1014,7 @@ def get_tracker_aggregate_forward(self):
         @return URL """
         return self.sessconfig['tracker_aggregate_forward']
 
-    def set_tracker_aggregator(self,value):
+    def set_tracker_aggregator(self, value):
         """ Whether to act as a data aggregator rather than a tracker.
         To enable, set to True or ; if password is set, then an
         incoming password is required for access.
@@ -1015,7 +1027,7 @@ def get_tracker_aggregator(self):
         @return Boolean or string. """
         return self.sessconfig['tracker_aggregator']
 
-    def set_tracker_multitracker_http_timeout(self,value):
+    def set_tracker_multitracker_http_timeout(self, value):
         """ Time to wait before assuming that an HTTP connection
         to another tracker in a multi-tracker setup has timed out.
         @param value A number of seconds.
@@ -1031,7 +1043,7 @@ def get_tracker_multitracker_http_timeout(self):
     #
     # For Tribler superpeer servers
     #
-    def set_superpeer(self,value):
+    def set_superpeer(self, value):
         """ Run Session in super peer mode (default = disabled).
         @param value Boolean.
         """
@@ -1042,7 +1054,7 @@ def get_superpeer(self):
         @return Boolean. """
         return self.sessconfig['superpeer']
 
-    def set_superpeer_file(self,value):
+    def set_superpeer_file(self, value):
         """ File with addresses of superpeers (default = install_dir+
         Tribler/Core/superpeer.txt).
         @param value An absolute path name.
@@ -1054,7 +1066,7 @@ def get_superpeer_file(self):
         @return An absolute path name. """
         return self.sessconfig['superpeer_file']
 
-    def set_overlay_log(self,value):
+    def set_overlay_log(self, value):
         """ File to log message to in super peer mode (default = No logging)
         @param value An absolute path name.
         """
@@ -1067,12 +1079,12 @@ def get_overlay_log(self):
 
     # ProxyService_
     #
-    def set_proxy_default_dlcfg(self,dscfg):
+    def set_proxy_default_dlcfg(self, dscfg):
         """ Sets the DownloadStartupConfig with which to start new Proxy Downloads
         when the client is asked to relay as a proxy.
         """
         c = dscfg.copy()
-        self.sessconfig['proxy_default_dlcfg'] = c.dlconfig # copy internal dict
+        self.sessconfig['proxy_default_dlcfg'] = c.dlconfig  # copy internal dict
 
     def get_proxy_default_dlcfg(self):
         """ Returns the DownloadStartupConfig with which to start new Proxy Downloads
@@ -1092,7 +1104,7 @@ def get_proxy_default_dlcfg(self):
     #
     # NAT Puncturing servers information setting
     #
-    def set_nat_detect(self,value):
+    def set_nat_detect(self, value):
         """ Whether to try to detect the type of Network Address Translator
         in place.
         @param value Boolean.
@@ -1154,7 +1166,7 @@ def get_crawler(self):
     #
     # Local Peer Discovery using IP Multicast
     #
-    def set_multicast_local_peer_discovery(self,value):
+    def set_multicast_local_peer_discovery(self, value):
         """ Set whether the Session tries to detect local peers
         using a local IP multicast. Overlay swarm (set_overlay()) must
         be enabled as well.
@@ -1262,7 +1274,7 @@ def get_dispersy_port(self):
     #
     # SWIFTPROC
     #
-    def set_swift_proc(self,value):
+    def set_swift_proc(self, value):
         """ Enable/disable support for swift Downloads via an external
         swift C++ process.
         @param value  Boolean
@@ -1276,7 +1288,7 @@ def get_swift_proc(self):
         """
         return self.sessconfig['swiftproc']
 
-    def set_swift_path(self,value):
+    def set_swift_path(self, value):
         """ Path to swift binary (default = None = /swift[.exe])
         @param value An absolute path name.
         """
@@ -1285,9 +1297,9 @@ def set_swift_path(self,value):
     def get_swift_path(self):
         """ Returns the path of the swift binary.
         @return An absolute path name. """
-        return self.sessconfig['swiftpath'] # strings immutable
+        return self.sessconfig['swiftpath']  # strings immutable
 
-    def set_swift_working_dir(self,value):
+    def set_swift_working_dir(self, value):
         """ Current working directory for swift binary (default = '.')
         @param value A path name.
         """
@@ -1296,9 +1308,9 @@ def set_swift_working_dir(self,value):
     def get_swift_working_dir(self):
         """ Returns the working directory for the swift binary.
         @return A path name. """
-        return self.sessconfig['swiftworkingdir'] # strings immutable
+        return self.sessconfig['swiftworkingdir']  # strings immutable
 
-    def set_swift_cmd_listen_port(self,port):
+    def set_swift_cmd_listen_port(self, port):
         """ Set the local TCP listen port for cmd socket communication to
         the swift processes (unused). CMD listen port of swift process itself
         is set via DownloadConfig.set_swift_cmdgw_listen_port() (download-to-process
@@ -1313,7 +1325,7 @@ def get_swift_cmd_listen_port(self):
         return self.sessconfig['swiftcmdlistenport']
 
 
-    def set_swift_downloads_per_process(self,value):
+    def set_swift_downloads_per_process(self, value):
         """ Number of downloads per swift process. When exceeded, a new swift
         process is created. Only used when the user did not specify ports
         for the swift process via DownloadConfig.set_swift_*_port()
@@ -1330,7 +1342,7 @@ def get_swift_downloads_per_process(self):
     #
     # Config for swift tunneling e.g. dispersy traffic
     #
-    def set_swift_tunnel_listen_port(self,port):
+    def set_swift_tunnel_listen_port(self, port):
         """ Set the UDP port for the swift process
         (download-to-process mapping permitting).
         @param port A port number.
@@ -1343,7 +1355,7 @@ def get_swift_tunnel_listen_port(self):
         @return Port number. """
         return self.sessconfig['swifttunnellistenport']
 
-    def set_swift_tunnel_cmdgw_listen_port(self,port):
+    def set_swift_tunnel_cmdgw_listen_port(self, port):
         """ Set the TCP listen port for the CMDGW of the swift process
         (download-to-process mapping permitting).
         @param port A port number.
@@ -1357,7 +1369,7 @@ def get_swift_tunnel_cmdgw_listen_port(self):
         @return Port number. """
         return self.sessconfig['swifttunnelcmdgwlistenport']
 
-    def set_swift_tunnel_httpgw_listen_port(self,port):
+    def set_swift_tunnel_httpgw_listen_port(self, port):
         """ Set the TCP listen port for the CMDGW of the swift process
         (download-to-process mapping permitting).
         @param port A port number.
@@ -1373,11 +1385,11 @@ def get_swift_tunnel_httpgw_listen_port(self):
 
 
 
-class SessionStartupConfig(SessionConfigInterface,Copyable,Serializable):
+class SessionStartupConfig(SessionConfigInterface, Copyable, Serializable):
     """ Class to configure a Session """
 
-    def __init__(self,sessconfig=None):
-        SessionConfigInterface.__init__(self,sessconfig)
+    def __init__(self, sessconfig=None):
+        SessionConfigInterface.__init__(self, sessconfig)
 
     #
     # Class method
@@ -1390,20 +1402,20 @@ def load(filename):
         @return SessionStartupConfig object
         """
         # Class method, no locking required
-        f = open(filename,"rb")
+        f = open(filename, "rb")
         sessconfig = pickle.load(f)
         sscfg = SessionStartupConfig(sessconfig)
         f.close()
         return sscfg
     load = staticmethod(load)
 
-    def save(self,filename):
+    def save(self, filename):
         """ Save the SessionStartupConfig to disk.
         @param filename  An absolute Unicode filename
         """
         # Called by any thread
-        f = open(filename,"wb")
-        pickle.dump(self.sessconfig,f)
+        f = open(filename, "wb")
+        pickle.dump(self.sessconfig, f)
         f.close()
 
     #
diff --git a/Tribler/Main/tribler.py b/Tribler/Main/tribler.py
index 748c0a4fcc2..c0da3311fb2 100644
--- a/Tribler/Main/tribler.py
+++ b/Tribler/Main/tribler.py
@@ -346,51 +346,30 @@ def startAPI(self, progress):
         if create_new:
             self.sconfig = SessionStartupConfig()
             self.sconfig.set_state_dir(state_dir)
+            self.sconfig.set_nat_detect(True)
 
-            # Set default Session params here
+        # Set default Session params here
+        if not self.sconfig.get_dest_dir():
             destdir = get_default_dest_dir()
-            torrcolldir = os.path.join(destdir, STATEDIR_TORRENTCOLL_DIR)
-            self.sconfig.set_torrent_collecting_dir(torrcolldir)
-
-            self.sconfig.set_nat_detect(True)
+            self.sconfig.set_dest_dir(destdir)
 
-            # Arno, 2012-05-04: swift
-            self.sconfig.set_swift_tunnel_listen_port(7758)
-            self.sconfig.set_swift_tunnel_httpgw_listen_port(17758)
-            self.sconfig.set_swift_tunnel_cmdgw_listen_port(27758)
+        if not os.path.isdir(self.sconfig.get_dest_dir()):
+            os.makedirs(self.sconfig.get_dest_dir())
 
-            # rename old collected torrent directory
-            try:
-                if not os.path.exists(destdir):
-                    os.makedirs(destdir)
-                old_collected_torrent_dir = os.path.join(state_dir, 'torrent2')
-                if not os.path.exists(torrcolldir) and os.path.isdir(old_collected_torrent_dir):
-                    os.rename(old_collected_torrent_dir, torrcolldir)
-                    print >> sys.stderr, "main: Moved dir with old collected torrents to", torrcolldir
-
-                # Arno, 2008-10-23: Also copy torrents the user got himself
-                old_own_torrent_dir = os.path.join(state_dir, 'torrent')
-                for name in os.listdir(old_own_torrent_dir):
-                    oldpath = os.path.join(old_own_torrent_dir, name)
-                    newpath = os.path.join(torrcolldir, name)
-                    if not os.path.exists(newpath):
-                        print >> sys.stderr, "main: Copying own torrent", oldpath, newpath
-                        os.rename(oldpath, newpath)
-
-                # Internal tracker
-            except:
-                print_exc()
-
-        # 22/08/08 boudewijn: convert abc.conf to SessionConfig
-        self.utility.convert__presession_4_1__4_2(self.sconfig)
+        if not self.sconfig.get_torrent_collecting_dir():
+            torrcolldir = os.path.join(self.sconfig.get_dest_dir(), STATEDIR_TORRENTCOLL_DIR)
+            self.sconfig.set_torrent_collecting_dir(torrcolldir)
 
         # Arno, 2010-03-31: Hard upgrade to 50000 torrents collected
         self.sconfig.set_torrent_collecting_max_torrents(50000)
 
         # Arno, 2012-05-04: swift
-        self.sconfig.set_swift_tunnel_listen_port(7758)
-        self.sconfig.set_swift_tunnel_httpgw_listen_port(17758)
-        self.sconfig.set_swift_tunnel_cmdgw_listen_port(27758)
+        if not self.sconfig.get_swift_cmd_listen_port():
+            self.sconfig.set_swift_tunnel_listen_port(7758)
+        if not self.sconfig.get_swift_tunnel_httpgw_listen_port():
+            self.sconfig.set_swift_tunnel_httpgw_listen_port(17758)
+        if not self.sconfig.get_swift_tunnel_cmdgw_listen_port():
+            self.sconfig.set_swift_tunnel_cmdgw_listen_port(27758)
 
         # Niels, 2011-03-03: Working dir sometimes set to a browsers working dir
         # only seen on windows