Esempio n. 1
0
	def check_for_changes(self,source_dir=os.getcwd()):
	#check database for list of files and last modified date,
	#	compare to all files in root directory (except lib).
	#	if different, call update_library
		CMP.info("looking for new tracks...")

		#get all current files
		filesongs=[]
		acceptable_filetypes = [".mp3"] #TODO replace with config file
		for root, dirs, files in os.walk(source_dir):
			for f in files:
				source = root+"/"+f
				extension = os.path.splitext(source)[1].lower()
				if extension in acceptable_filetypes:
					filesongs.append(str(os.path.getmtime(source))+"|"+source)

		#get database's (old) files
		dbsongs=[]
		self.cursor.execute('SELECT file, modified FROM library')
		result=self.cursor.fetchall()
		for a in result:
			dbsongs.append(a[1]+"|"+a[0])
		
		#now compare
		#filesongs.sort()
		#dbsongs.sort()
		missing_from_db=list(set(filesongs).difference(set(dbsongs)))
		missing_from_files=list(set(dbsongs).difference(set(filesongs)))
		for m in missing_from_db:
			self.add_to_library(re.split('\|',m,1)[1])
		for m in missing_from_files:
			self.remove_from_library(re.split('\|',m,1)[1])
		#waiting to push the changes until now means we can be sure there
		#	aren't any crashes that f**k our database.
		self.connection.commit()
Esempio n. 2
0
	def __init__(self):
		self.cursor.execute('SELECT name FROM sqlite_master WHERE type=\'table\'')
		result=self.cursor.fetchall()
		if not ('config',) in result:
			CMP.warn('config table missing. Creating...')
			self.initalize_config()
		self.extract_settings()
Esempio n. 3
0
def play(song_id):
    myplayer = Player()
    filepath = cmpdb.get_file(song_id)
    if filepath != -1:
        myplayer.start(filepath)
        while myplayer.playmode:
            time.sleep(5)
            print myplayer.playmode
    else:
        CMP.error("No such song!")
Esempio n. 4
0
	def __init__(self,library_dir):
		self.library_create = 'CREATE TABLE library (song_id INTEGER PRIMARY KEY, file VARCHAR(255), tracknum INT(8), title VARCHAR(255), artist VARCHAR(255), album VARCHAR(255), year INT(16), modified VARCHAR(20))'
		self.library_insert = 'INSERT INTO library VALUES (null, ?, ?, ?, ?, ?, ?, ?)'
		self.library_dir = library_dir

		#add the library table if it doesn't exist
		self.cursor.execute('SELECT name FROM sqlite_master WHERE type=\'table\'')
		result=self.cursor.fetchall()
		if not ('library',) in result:
			CMP.warn('library table missing. Creating...')
			self.cursor.execute(self.library_create)
			self.connection.commit()
		self.check_for_changes()
Esempio n. 5
0
	def __init__(self, playqueue):
		if str(playqueue.__class__) != "CMP.playqueue.PlayQueue":
			CMP.error("that ain't no playqueue!")
		else:
			self.playqueue = '' #playqueuefile
		self.pipeline = gst.Pipeline('player')

		self.filesrc = gst.element_factory_make('audiotestsrc', None)
		self.pipeline.add(self.filesrc)
		#set_property('location', '///')

		#self.decodebin = gst.element_factory_make('decodebin', None)
		#self.pipeline.add(self.decodebin)
		#self.filesrc.link(self.decodebin)

		#self.audioconvert=gst.element_factory_make('audioconvert', None)
		#self.pipeline.add(self.audioconvert)
		##self.decodebin.link(self.audioconvert)

		self.alsasink = gst.element_factory_make('alsasink', None)
		self.pipeline.add(self.alsasink)
		#self.audioconvert.link(self.alsasink)

		self.filesrc.link(self.alsasink)
		# gst.element_link_many


		self.play("n")
		#freq=200
		#dorian minor
		freqs=[587.329535834815,
			659.25511382574,
			698.456462866008,
			783.990871963499,
			880,
			987.766602512248,
			1046.50226120239,
			1174.65907166963,
			146.832383958704,
			164.813778456435,
			174.614115716502,
			195.997717990875,
			220,
			246.941650628062,
			261.625565300599,
			293.664767917408]
		for i in freqs:
			self.filesrc.set_property("freq", i)
			time.sleep(2)
		self.pause()
Esempio n. 6
0
	def __init__(self):
		#PIPE is of the form [ (element, [[property,] property...]), ...] in pipeline order
		self.pipe=[('filesrc', 'location'), ('decodebin',), ('audioconvert',), ('alsasink',)]
		self.pipeline = gst.Pipeline('player')
		i=0
		self.elements=[]
		for element in self.pipe: #this is stupid
			print "appending"
			self.elements.append(gst.element_factory_make(element[0], None))
			print "adding to pipeline"
			self.pipeline.add(self.elements[i])
			#add properties
			for j in range(1, len(elements)):
				pass
			#link to previous
			if (i>1):
				try:
					self.elements[i-1].link(self.elements[i])
				except Exception, err:
					CMP.error(err.message)
			i+=1
Esempio n. 7
0
	def remove_from_library(self,songfile):
		CMP.warn("track "+songfile+" is missing. removing from database")
		self.cursor.execute('DELETE FROM library WHERE file =?',(songfile,))
Esempio n. 8
0
	def add_to_library(self,songfile):
		mytagger = tagger()
		tags = mytagger.get_track_info(songfile)
		CMP.warn("adding "+songfile)
		self.cursor.execute(self.library_insert, ( songfile, tags['tracknum'], tags["title"], tags["artist"], tags["album"], tags['year'], str(os.path.getmtime(songfile)) ) )
Esempio n. 9
0
# Log in to CMP
# Written by Shragovich Eugene 2014

import logging
import time
import config
import generics
from CMP import *

#ENV SETTINGS
testName = testName = (inspect.getfile(inspect.currentframe()).split("\\", -1)[-1]).rsplit(".", 1)[0] #Extract current *.py file name

CMP = CMP(testName)

setBundlePath(config.bundlePath)
setShowActions(CMP.debug)

#Logging configuration
localLog = logging.getLogger(testName)

### START ###
localLog.info("### Going to run a test: %s ###", testName)

# Init test status to fail
generics.setTestStatus("TEST_INIT", 1, testName)

# Access the application
CMP.access()

# Exit the application
CMP.logOut()