samba-tool: Use self.outf in a few more places.
[Samba/gebeck_regimport.git] / source4 / scripting / python / samba / netcmd / time.py
blob31a6f7c627843c7f6e4aaa3cf0406e6b4053b813
1 #!/usr/bin/env python
3 # time
5 # Copyright Jelmer Vernooij 2010 <jelmer@samba.org>
6 # Copyright Giampaolo Lauria 2011 <lauria2@yahoo.com>
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 import samba.getopt as options
23 import common
24 from samba.net import Net
26 from samba.netcmd import (
27 Command,
30 class cmd_time(Command):
31 """Retrieve the time on a remote server"""
32 synopsis = "%prog time [server-name] [options]"
34 takes_args = ["server_name?"]
36 def run(self, server_name=None, credopts=None, sambaopts=None, versionopts=None):
37 lp = sambaopts.get_loadparm()
38 creds = credopts.get_credentials(lp, fallback_machine=True)
39 net = Net(creds, lp, server=credopts.ipaddress)
40 if server_name is None:
41 server_name = common.netcmd_dnsname(lp)
42 self.outf.write(net.time(server_name)+"\n")