~chipaca/ubuntuone-windows-installer/miscelanea

« back to all changes in this revision

Viewing changes to src/u1sync/sync.py

  • Committer: Manuel de la Pena
  • Date: 2010-11-02 22:01:15 UTC
  • mfrom: (84.4.13 performance_iprove)
  • Revision ID: mandel@themacaque.com-20101102220115-3ys5bku6j6ddwpik
Improve performance by removing the use of WCF since is not required right now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import os
26
26
 
27
27
EMPTY_HASH = ""
28
 
UPLOAD_SYMBOL = u"\u25b2".encode("utf-8")
29
 
DOWNLOAD_SYMBOL = u"\u25bc".encode("utf-8")
 
28
UPLOAD_SYMBOL = "^"
 
29
DOWNLOAD_SYMBOL = "v"
30
30
CONFLICT_SYMBOL = "!"
31
31
DELETE_SYMBOL = "X"
32
32
 
35
35
    DIRECTORY, SYMLINK)
36
36
from u1sync.genericmerge import (
37
37
    MergeNode, generic_merge)
38
 
from u1sync.utils import safe_mkdir
 
38
from u1sync.utils import safe_mkdir, send_notification
39
39
from u1sync.client import UnsupportedOperationError
40
40
 
41
41
def get_conflict_path(path, conflict_info):
46
46
 
47
47
def name_from_path(path):
48
48
    """Returns unicode name from last path component."""
49
 
    return os.path.split(path)[1].decode("UTF-8")
 
49
    return os.path.split(path)[1]
50
50
 
51
51
 
52
52
class NodeSyncError(Exception):
75
75
        (parent_path, parent_display_path, parent_uuid, parent_synced) \
76
76
            = partial_parent
77
77
 
78
 
        utf8_name = name
79
 
        path = os.path.join(parent_path, utf8_name)
80
 
        display_path = os.path.join(parent_display_path, utf8_name)
 
78
        path = os.path.join(parent_path, name)
 
79
        display_path = os.path.join(parent_display_path, name)
81
80
        node_uuid = None
82
81
 
83
82
        synced = False
89
88
                else:
90
89
                    if not quiet:
91
90
                        print "%s   %s" % (sync_mode.symbol, display_path)
 
91
                    if(sync_mode.symbol == DOWNLOAD_SYMBOL):
 
92
                        send_notification("Downloading", "Downloading file '%s'" % display_path, "info")
 
93
                    elif(sync_mode.symbol == UPLOAD_SYMBOL):
 
94
                        send_notification("Uploading", "Uploading file '%s'" % display_path, "info")
 
95
                    send_notification()
92
96
                    try:
93
97
                        create_dir = sync_mode.create_directory
94
98
                        node_uuid = create_dir(parent_uuid=parent_uuid,
236
240
        """Creates a directory."""
237
241
        try:
238
242
            safe_mkdir(path)
 
243
            send_notification("New dir", "Creating dir %s" % path)
239
244
        except OSError, e:
240
245
            raise NodeCreateError("Error creating local directory %s: %s" % \
241
246
                                  (path, e))