SugarSync Python API guide

SugarSync.init(self, conf=None, username=None, password=None, apikey=None, privatekey=None)

Initialize the python sugar sync api. This initialization can take place ether via configuration file (by passing ConfigParser.RawConfigParser() into init with a config file storing username, password, apikey, and privatekey) or via parameter (passing username, password, apikey, and privatekey directly).

Example using config file
conf = ConfigParser.RawConfigParser()
conf.read("conf.ini")
q = SugarSync(conf=conf)

Example using parameter
# all values strings
q = SugarSync(username=uname, password=passwd, apikey=apikey, privatekey=privatekey)

SugarSync.ListSyncFolders(self)

Lists all top level sync folders that are currently synced with SugarSync. This function returns a list of SyncFolder Class.

Example
q = SugarSync(conf=conf)
folders = q.ListSyncFolders()

SugarSync.GetFolders(self, folder)

List all subfolders inside of a particular folder. This class takes a SyncFolder Class that was obtained ether via this function of SugarSync.ListSyncFolder(), Returns a list of SyncFolder Class.

Example
q = SugarSync(conf=conf)
folders = q.ListSyncFolders()
subfolders = q.GetFolders(folders[0])

SugarSync.ListFiles(self, folder)

List all files inside of a folder. Returns a list of SyncFile Class.

Example
q = SugarSync(conf=conf)
folders = q.ListSyncFolders()
subfolders = q.GetFolders(folders[0])
files = q.ListFiles(subfolders[0])

SugarSync.GetFile(self, file)

Get file data. Takes a SyncFile Class as input. Returns a tuple containing (length, data).

Example
q = SugarSync(conf=conf)
folders = q.ListSyncFolders()
subfolders = q.GetFolders(folders[0])
files = q.ListFiles(subfolders[0])
data = q.GetFile(files[0])

SugarSync.WriteFile(self, file, data)

Write data to a file. Takes a SyncFile Class and a data string as input. Returns true if write successful, false if failure.

Example

q = SugarSync(conf=conf)
folders = q.ListSyncFolders()
subfolders = q.GetFolders(folders[0])
files = q.ListFiles(subfolders[0])
writeok = q.WriteFile(files[0], "SOME DATA HERE!")

SugarSync.CreateFolder(self, parentfolder, foldername)

Creates a folder. Takes a Parent Folder (SyncFolder Class) and a Folder Name (string) as inputs. Returns
true if folder created. False if creation failed.

Example

q = SugarSync(conf=conf)
folders = q.ListSyncFolders()
subfolders = q.GetFolders(folders[0])
status = q.CreateFolder(subfolders[0], 'NewFolder')

SugarSync.CreateFile(self, folder, filename)

Creates a file in the folder specified. Takes a folder (SyncFolder Class) and a file name (string). Returns
true if the file was created. False if it was not.

Example
q = SugarSync(conf=conf)
folders = q.ListSyncFolders()
subfolders = q.GetFolders(folders[0])
status = q.CreateFile(subfolders[0], 'TestFile')

SugarSync.DeleteFile(self, file)

Remove a file from SugarSync. Takes a SyncFile Class as input. Returns true on deletion, false on failure.

Example
q = SugarSync(conf=conf)
folders = q.ListSyncFolders()
subfolders = q.GetFolders(folders[0])
files = q.ListFiles(subfolders[0])
data = q.DeleteFile(files[0])

SugarSync.DeleteFolder(self, folder)

Remove a folder from SugarSync. Takes a SyncFolder Class as input. Returns true on deletion

Example
q = SugarSync(conf=conf)
folders = q.ListSyncFolders()
subfolders = q.GetFolders(folders[0])
data = q.DeleteFolder(subfolders[0])