How to use MM COM objects with a test MM database?

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey.

Moderator: Gurus

How to use MM COM objects with a test MM database?

Postby Barry4679 » Fri May 26, 2017 9:12 pm

I am testing an external (python) application using MM automation objects.

ie. SDB = win32com.client.Dispatch("SongsDB.SDBApplication")

If MM is not already running, it is invoked, and its database is pointed at my production MM database, as per the MediaMonkey.ini found at C:\Users\xxxx\AppData\Roaming\MediaMonkey

Is there a way to override which inifile is used, so that I can point it at a test MM database?
Barry4679
 
Posts: 253
Joined: Fri Sep 11, 2009 8:07 am
Location: Australia

Re: How to use MM COM objects with a test MM database?

Postby Barry4679 » Fri May 26, 2017 10:14 pm

a workaround is to try to remember to pre-start MM with a inifile override on the command line.
Barry4679
 
Posts: 253
Joined: Fri Sep 11, 2009 8:07 am
Location: Australia

Re: How to use MM COM objects with a test MM database?

Postby Peke » Sun May 28, 2017 4:59 pm

Hi,
Have you tried to install MMW as Service?
Best regards,
Pavle
MM Core Developer and Admin of free MediaMonkey extensions Hosting
Image
Image
Peke
 
Posts: 10492
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia

Re: How to use MM COM objects with a test MM database?

Postby Barry4679 » Tue May 30, 2017 3:08 am

Peke wrote:Have you tried to install MMW as Service?

No.
Could you explain how that would help me?

I want to:
* use MM normally, with it pointing to my production database
* but when testing the COM app, I want that test run to be updating my test MM.db

My workaround, is to:
* close down MM prior to the test
* restart MM using a command line, which overrides to a testing ini file, pointing to the test MM.db
* test the COM application ... it uses the running invocation, ie. the test MM.db
* close down MM after the test, and then restart MM with the regular ini file

I was just wondering if there was something more idiot-proof.

Are you meaning that I can get the COM connection to attach to a testing secondary MM invocation?
something other than SDB = win32com.client.Dispatch("SongsDB.SDBApplication")?
How would I start|name this secondary invocation, and how would I get it to use a testing ini file?


Maybe it would be best to do my testing inside a VM?
Barry4679
 
Posts: 253
Joined: Fri Sep 11, 2009 8:07 am
Location: Australia

Re: How to use MM COM objects with a test MM database?

Postby rivorson » Tue May 30, 2017 9:29 am

Running a VM is always a good option but I think you've got the right approach. One thing you might change is allowing multiple instances of MM so you wouldn't need to close the instance running your production database before opening the instance with your test database.

The option is Tools --> Options --> General --> Allow just one instance of MediaMonkey.
rivorson
 
Posts: 529
Joined: Thu Jul 25, 2013 4:17 am

Re: How to use MM COM objects with a test MM database?

Postby Barry4679 » Wed May 31, 2017 8:57 pm

rivorson wrote:One thing you might change is allowing multiple instances of MM so you wouldn't need to close the instance running your production database before opening the instance with your test database.


Thanks.

My COM knowledge doesn't extend much beyond the supplied MediaMonkey documentation. I am just following the advice showing how to establish a connection using Python, ie.
SDB = win32com.client.Dispatch("SongsDB.SDBApplication")

If I had a 2nd version of MM running how would I connect to the correct instance?
Barry4679
 
Posts: 253
Joined: Fri Sep 11, 2009 8:07 am
Location: Australia

Re: How to use MM COM objects with a test MM database?

Postby Just Guessing » Tue Jul 18, 2017 8:25 am

If I had a 2nd version of MM running how would I connect to the correct instance?


ALSO INTERESTED.

I experimented for 2/3 days with such a pursuit and concluded its not gonna happen without major experimental hacking of installation registry files. I'd love it if someone can share/reveal a clean method to use multiple MM windows through scripting or command line.
Just Guessing
 
Posts: 64
Joined: Mon Sep 03, 2012 12:06 pm

Re: How to use MM COM objects with a test MM database?

Postby Peke » Wed Jul 26, 2017 8:58 pm

Hi,
You can get iDispatch address from MMW internal Script start so that access works even on MMW portable.
Best regards,
Pavle
MM Core Developer and Admin of free MediaMonkey extensions Hosting
Image
Image
Peke
 
Posts: 10492
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia

Re: How to use MM COM objects with a test MM database?

Postby Barry4679 » Fri Aug 11, 2017 9:41 pm

Peke wrote:Hi,
You can get iDispatch address from MMW internal Script start so that access works even on MMW portable.


I just noticed this.

I am sorry. I don't understand.

In a Python context, I do the following (from docs)

SDB = win32com.client.Dispatch("SongsDB.SDBApplication")

How do I apply your advice?
Barry4679
 
Posts: 253
Joined: Fri Sep 11, 2009 8:07 am
Location: Australia

Re: How to use MM COM objects with a test MM database?

Postby Peke » Fri Aug 25, 2017 4:48 pm

And windows determine which instance it will return we have never found the way to control it.
Best regards,
Pavle
MM Core Developer and Admin of free MediaMonkey extensions Hosting
Image
Image
Peke
 
Posts: 10492
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia


Return to MediaMonkey 4 Addons developer forum

Who is online

Users browsing this forum: No registered users and 6 guests