Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerikb <erikb@574bc980-5f2d-0410-acbc-c8f9f0eb14e0>2007-11-01 00:12:12 (GMT)
committer erikb <erikb@574bc980-5f2d-0410-acbc-c8f9f0eb14e0>2007-11-01 00:12:12 (GMT)
commitb256c95ce2393dd76718951b9a4417e71abcc8a8 (patch)
tree920fb934c4e7b887f500120d31971c30e29473dd
parentb484ad8606ac962dfc7b6a0036d9d605e2794cb2 (diff)
more refactor fixes
git-svn-id: http://mediamods.com/public-svn/camera-activity/Record.activity@798 574bc980-5f2d-0410-acbc-c8f9f0eb14e0
-rw-r--r--button.py20
-rw-r--r--instance.py1
-rw-r--r--model.py13
-rwxr-xr-xrecord.py2
-rw-r--r--serialize.py49
-rw-r--r--ui.py1
-rw-r--r--utils.py2
7 files changed, 46 insertions, 42 deletions
diff --git a/button.py b/button.py
index 425b589..62a989e 100644
--- a/button.py
+++ b/button.py
@@ -8,6 +8,8 @@ from sugar.graphics.palette import Palette
from sugar.graphics.tray import TrayButton
from sugar.graphics.icon import Icon
from sugar.graphics import style
+from constants import Constants
+import utils
class RecdButton(TrayButton, gobject.GObject):
def __init__(self, ui, recd):
@@ -29,32 +31,32 @@ class RecdButton(TrayButton, gobject.GObject):
xoff = 0
yoff = 0
pb = None
- if (self.recd.type == constants.TYPE_PHOTO):
+ if (self.recd.type == Constants.TYPE_PHOTO):
xoff = 8
yoff = 8
if (self.recd.buddy):
- thumbPhotoSvg = self.ui.loadSvg(self.ui.thumbPhotoSvgData, self.recd.colorStroke.hex, self.recd.colorFill.hex)
+ thumbPhotoSvg = utils.loadSvg(Constants.thumbPhotoSvgData, self.recd.colorStroke.hex, self.recd.colorFill.hex)
pb = thumbPhotoSvg.get_pixbuf()
else:
- pb = self.ui.thumbPhotoSvg.get_pixbuf()
+ pb = Constants.thumbPhotoSvg.get_pixbuf()
- elif (self.recd.type == constants.TYPE_VIDEO):
+ elif (self.recd.type == Constants.TYPE_VIDEO):
xoff = 8
yoff = 22
if (self.recd.buddy):
- thumbVideoSvg = self.ui.loadSvg(self.ui.thumbVideoSvgData, self.recd.colorStroke.hex, self.recd.colorFill.hex)
+ thumbVideoSvg = utils.loadSvg(Constants.thumbVideoSvgData, self.recd.colorStroke.hex, self.recd.colorFill.hex)
pb = thumbVideoSvg.get_pixbuf()
else:
- pb = self.ui.thumbVideoSvg.get_pixbuf()
+ pb = Constants.thumbVideoSvg.get_pixbuf()
- elif (self.recd.type == constants.TYPE_AUDIO):
+ elif (self.recd.type == Constants.TYPE_AUDIO):
xoff = 8
yoff = 22
if (self.recd.buddy):
- thumbAudioSvg = self.ui.loadSvg(self.ui.thumbAudioSvgData, self.recd.colorStroke.hex, self.recd.colorFill.hex)
+ thumbAudioSvg = utils.loadSvg(Constants.thumbAudioSvgData, self.recd.colorStroke.hex, self.recd.colorFill.hex)
pb = thumbAudioSvg.get_pixbuf()
else:
- pb = self.ui.thumbVideoSvg.get_pixbuf()
+ pb = Constants.thumbVideoSvg.get_pixbuf()
img.set_from_pixbuf( pb )
img.show()
diff --git a/instance.py b/instance.py
index 9e238b2..5a9a7f7 100644
--- a/instance.py
+++ b/instance.py
@@ -3,6 +3,7 @@ import os
from sugar import profile
from sugar import util
from sugar.activity import activity
+import shutil
from color import Color
diff --git a/model.py b/model.py
index 53dc333..ef1d03b 100644
--- a/model.py
+++ b/model.py
@@ -29,18 +29,17 @@ import gtk
import gtk.gdk
import pygtk
pygtk.require('2.0')
-import shutil
import gc
import math
import time
from time import strftime
import gobject
-from hashlib import md5
import operator
from sugar.datastore import datastore
import sugar.env
+from record import Record
from constants import Constants
from instance import Instance
from recorded import Recorded
@@ -269,18 +268,18 @@ class Model:
def meshShareRecd( self, recd ):
- record.log.debug('meshShareRecd')
+ Record.log.debug('meshShareRecd')
#hey, i just took a cool video.audio.photo! let me show you!
if (self.ca.recTube != None):
- self.ca._logger.debug('meshShareRecd: we have a recTube')
+ Record.log.debug('meshShareRecd: we have a recTube')
recdXml = self.ca.getRecdXmlString(recd)
- self.ca._logger.debug('meshShareRecd: created XML')
+ Record.log.debug('meshShareRecd: created XML')
self.ca.recTube.notifyBudsOfNewRecd( Instance.keyHashPrintable, recdXml )
- self.ca._logger.debug('meshShareRecd: notifyBuds')
+ Record.log.debug('meshShareRecd: notifyBuds')
def cannotSaveVideo( self ):
- self.ca._logger.debug("bad recorded video")
+ Record.log.debug("bad recorded video")
self.doPostSaveVideo()
diff --git a/record.py b/record.py
index 25f70bc..58036a4 100755
--- a/record.py
+++ b/record.py
@@ -436,7 +436,7 @@ class Record(activity.Activity):
recd.meshDownloading = False
recd.meshDownlodingPercent = 1.0
recd.downloadedFromBuddy = True
- if (recd.type == constants.TYPE_AUDIO):
+ if (recd.type == Constants.TYPE_AUDIO):
self.connect(greplay.getAlbumArt, recd, _getAlbumArtCb)
else:
self.ui.showMeshRecd( recd )
diff --git a/serialize.py b/serialize.py
index f434c5e..7ec4730 100644
--- a/serialize.py
+++ b/serialize.py
@@ -202,28 +202,28 @@ def getRecdXmlString( recd ):
return writer.getvalue()
-def addRecdXmlAttrs( self, el, recd, forMeshTransmit ):
+def addRecdXmlAttrs( el, recd, forMeshTransmit ):
el.setAttribute(self.recdType, str(recd.type))
- if ((recd.type == constants.TYPE_AUDIO) and (not forMeshTransmit)):
+ if ((recd.type == Constants.TYPE_AUDIO) and (not forMeshTransmit)):
aiPixbuf = recd.getAudioImagePixbuf( )
aiPixbufString = str( utils.getStringFromPixbuf(aiPixbuf) )
el.setAttribute(self.recdAudioImage, aiPixbufString)
if ((recd.datastoreId != None) and (not forMeshTransmit)):
- el.setAttribute(self.recdDatastoreId, str(recd.datastoreId))
+ el.setAttribute(Constants.recdDatastoreId, str(recd.datastoreId))
- el.setAttribute(self.recdTitle, recd.title)
- el.setAttribute(self.recdTime, str(recd.time))
- el.setAttribute(self.recdRecorderName, recd.recorderName)
- el.setAttribute(self.recdRecorderHash, str(recd.recorderHash) )
- el.setAttribute(self.recdColorStroke, str(recd.colorStroke.hex) )
- el.setAttribute(self.recdColorFill, str(recd.colorFill.hex) )
- el.setAttribute(self.recdBuddy, str(recd.buddy))
- el.setAttribute(self.recdMediaMd5, str(recd.mediaMd5))
- el.setAttribute(self.recdThumbMd5, str(recd.thumbMd5))
- el.setAttribute(self.recdMediaBytes, str(recd.mediaBytes))
- el.setAttribute(self.recdThumbBytes, str(recd.thumbBytes))
+ el.setAttribute(Constants.recdTitle, recd.title)
+ el.setAttribute(Constants.recdTime, str(recd.time))
+ el.setAttribute(Constants.recdRecorderName, recd.recorderName)
+ el.setAttribute(Constants.recdRecorderHash, str(recd.recorderHash) )
+ el.setAttribute(Constants.recdColorStroke, str(recd.colorStroke.hex) )
+ el.setAttribute(Constants.recdColorFill, str(recd.colorFill.hex) )
+ el.setAttribute(Constants.recdBuddy, str(recd.buddy))
+ el.setAttribute(Constants.recdMediaMd5, str(recd.mediaMd5))
+ el.setAttribute(Constants.recdThumbMd5, str(recd.thumbMd5))
+ el.setAttribute(Constants.recdMediaBytes, str(recd.mediaBytes))
+ el.setAttribute(Constants.recdThumbBytes, str(recd.thumbBytes))
def saveMediaHash( mediaTypes, mediaHashs ):
@@ -252,21 +252,24 @@ def saveMediaHash( mediaTypes, mediaHashs ):
recd = hash[i]
mediaEl = album.createElement( typeName )
root.appendChild( mediaEl )
- self._saveMedia( mediaEl, recd )
+
+ mtype = mediaTypes[recd.type]
+ mmime = mtype[Constants.keyMime]
+ _saveMedia( mediaEl, recd, mmime )
return album
-def _saveMedia( el, recd ):
+def _saveMedia( el, recd, mime ):
if ( (recd.buddy == True) and (recd.datastoreId == None) and (not recd.downloadedFromBuddy) ):
pixbuf = recd.getThumbPixbuf( )
buddyThumb = str( utils.getStringFromPixbuf(pixbuf) )
- el.setAttribute(self.recdBuddyThumb, buddyThumb )
+ el.setAttribute(Constants.recdBuddyThumb, buddyThumb )
recd.savedMedia = True
- self._saveXml( el, recd )
+ _saveXml( el, recd )
else:
recd.savedMedia = False
- self._saveMediaToDatastore( el, recd )
+ _saveMediaToDatastore( el, recd )
def _saveXml( el, recd ):
@@ -292,10 +295,10 @@ def _saveMediaToDatastore( el, recd ):
#save the title to the xml
recd.savedMedia = True
- self._saveXml( xmlFile, el, recd )
+ _saveXml( xmlFile, el, recd )
else:
recd.savedMedia = True
- self._saveXml( xmlFile, el, recd )
+ _saveXml( xmlFile, el, recd )
else:
#this will remove the media from being accessed on the local disk since it puts it away into cold storage
@@ -310,8 +313,6 @@ def _saveMediaToDatastore( el, recd ):
colors = str(recd.colorStroke.hex) + "," + str(recd.colorFill.hex)
mediaObject.metadata['icon-color'] = colors
- mtype = self.m.mediaTypes[recd.type]
- mmime = mtype[Constants.keyMime]
mediaObject.metadata['mime_type'] = mmime
mediaObject.metadata['activity'] = Constants.activityId
@@ -327,4 +328,4 @@ def _saveMediaToDatastore( el, recd ):
recd.thumbFilename = None
recd.savedMedia = True
- self._saveXml( xmlFile, el, recd ) \ No newline at end of file
+ _saveXml( xmlFile, el, recd ) \ No newline at end of file
diff --git a/ui.py b/ui.py
index 3f6f6c1..ddfc0f6 100644
--- a/ui.py
+++ b/ui.py
@@ -52,6 +52,7 @@ from glive import LiveVideoWindow
from gplay import PlayVideoWindow
from recorded import Recorded
from button import RecdButton
+from record import Record
import utils
import _camera
diff --git a/utils.py b/utils.py
index e9cb606..f9d0c4d 100644
--- a/utils.py
+++ b/utils.py
@@ -4,7 +4,7 @@ import re
import os
import cairo
import gc
-
+from hashlib import md5
from sugar import util
import _camera