<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Chris,<div><br></div><div>I didn't write this, and I'm not too familiar with the code, but this is something we use in our Python testing framework to import images.</div><div>components/tools/OmeroPy/test/integration/libraray.py</div><div><br></div><div><br></div><div><div>&nbsp;&nbsp; &nbsp;def import_image(self, filename = None):</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if filename is None:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;filename = self.OmeroPy / ".." / ".." / ".." / "components" / "common" / "test" / "tinyTest.d3d.dv"</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;server = self.client.getProperty("omero.host")</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;port = self.client.getProperty("omero.port")</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;key = self.client.getSessionId()</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;# Search up until we find "OmeroPy"</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;dist_dir = self.OmeroPy / ".." / ".." / ".." / "dist"</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;args = ["python"]</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;args.append(str(path(".") / "bin" / "omero"))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;args.extend(["-s", server, "-k", key, "-p", port, "import", filename])</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;popen = subprocess.Popen(args, cwd=str(dist_dir), stdout=subprocess.PIPE, stderr=subprocess.PIPE)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;out, err = popen.communicate()</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;rc = popen.wait()</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if rc != 0:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;raise exceptions.Exception("import failed: [%r] %s\n%s" % (args, rc, err))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;pix_ids = []</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;for x in out.split("\n"):</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if x and x.find("Created") &lt; 0 and x.find("#") &lt; 0:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try: &nbsp; &nbsp;# if the line has an image ID...</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;imageId = str(long(x.strip()))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pix_ids.append(imageId)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;except: pass</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return pix_ids</div><div><br></div><div><br></div><div>Hopefully you can work out what you need from this.</div><div><br></div><div>&nbsp;&nbsp;Will.&nbsp;</div></div><div><br><div><div>On 18 May 2011, at 17:16, Wood, Christopher wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="EN-US" link="blue" vlink="purple"><div class="WordSection1"><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="color: rgb(31, 73, 125); ">Also, when I use the command line importer (using the python subprocess module), is there a good way to get the image id?<o:p></o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="color: rgb(31, 73, 125); "><o:p>&nbsp;</o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="color: rgb(31, 73, 125); ">Thanks again.<o:p></o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="color: rgb(31, 73, 125); ">Chris<o:p></o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="color: rgb(31, 73, 125); "><o:p>&nbsp;</o:p></span></div><div><div style="border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-top-style: solid; border-top-color: rgb(181, 196, 223); border-top-width: 1pt; padding-top: 3pt; padding-right: 0in; padding-bottom: 0in; padding-left: 0in; "><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><b><span style="font-size: 10pt; font-family: Tahoma, sans-serif; ">From:</span></b><span style="font-size: 10pt; font-family: Tahoma, sans-serif; "><span class="Apple-converted-space">&nbsp;</span><a href="mailto:ome-devel-bounces@lists.openmicroscopy.org.uk">ome-devel-bounces@lists.openmicroscopy.org.uk</a> [<a href="mailto:ome-devel-bounces@lists.openmicroscopy.org.uk" style="color: blue; text-decoration: underline; ">mailto:ome-devel-bounces@lists.openmicroscopy.org.uk</a>]<span class="Apple-converted-space">&nbsp;</span><b>On Behalf Of<span class="Apple-converted-space">&nbsp;</span></b>Wood, Christopher<br><b>Sent:</b><span class="Apple-converted-space">&nbsp;</span>Wednesday, May 18, 2011 11:10 AM<br><b>To:</b><span class="Apple-converted-space">&nbsp;</span><a href="mailto:ome-devel@lists.openmicroscopy.org.uk" style="color: blue; text-decoration: underline; ">ome-devel@lists.openmicroscopy.org.uk</a><br><b>Subject:</b><span class="Apple-converted-space">&nbsp;</span>[ome-devel] command line importer<o:p></o:p></span></div></div></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p>&nbsp;</o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; ">Hi,<o:p></o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p>&nbsp;</o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; ">Is there an option for the command line importer to archive the imported file(s) (so the originals can be downloaded later)?<o:p></o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p>&nbsp;</o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; ">Thanks<o:p></o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; ">Chris<o:p></o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p>&nbsp;</o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; ">--<o:p></o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; ">Chris Wood, Ph.D | Group Head - Stowers Microscopy Center<o:p></o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; ">Stowers Institute for Medical Research<o:p></o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; ">1000 E 50<sup>th</sup><span class="Apple-converted-space">&nbsp;</span>|Kansas City, MO 64110<o:p></o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><a href="http://www.stowers.org/" style="color: blue; text-decoration: underline; ">http://www.stowers.org</a><span class="Apple-converted-space">&nbsp;</span>|<span class="Apple-converted-space">&nbsp;</span><a href="mailto:cjw@stowers.org" style="color: blue; text-decoration: underline; ">cjw@stowers.org</a><o:p></o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p>&nbsp;</o:p></div></div>_______________________________________________<br>ome-devel mailing list<br><a href="mailto:ome-devel@lists.openmicroscopy.org.uk" style="color: blue; text-decoration: underline; ">ome-devel@lists.openmicroscopy.org.uk</a><br><a href="http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel" style="color: blue; text-decoration: underline; ">http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel</a><br></div></blockquote></div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>William Moore</div><div><div>Wellcome Trust Centre for Gene Regulation &amp; Expression</div><div>College of Life Sciences</div><div>MSI/WTB/JBC Complex</div><div>University of Dundee</div><div>Dow Street</div><div>Dundee&nbsp; DD1 5EH</div><div>United Kingdom</div><div><br></div><div>Phone 01382 386364</div></div><div><a href="http://openmicroscopy.org">http://openmicroscopy.org</a></div></div></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"> </div><br></div></body></html>