Hi Aaron,

On 2018-07-10 08:59, Chan, Aaron Chun Yew wrote:
My name is Aaron and not Aron for start

Sorry about that.

Martin,

Please try this

#!/usr/bin/env python2

import os

a = os.path.join('http://', 'alibaba.com')
b = '/'.join(['http://', 'alibaba.com'])
c = '/'.join(['http:/', 'alibaba.com', ''])

print(a)
print(b)
print(c)

and repeat the same for python3, I got the following results:

http://alibaba.com
http:///alibaba.com
http://alibaba.com/

I see, thanks for clarifying.

My initial concern was that `os.path.join()` was meant for OS independent path concatenation, and not constructing URLs.

My two first points still stand, though... Why not just string-concatenate the separate parts; i.e.

url = 'http://' + socket.getfqdn() + ':' + str(config.web_port) + '/'

But I won't stand in the way of the patch for such a stylish point, so feel free to ignore it :)

// Martin

Cheers,
Aaron
________________________________________
From: Martin Hundebøll [mar...@geanix.com]
Sent: Tuesday, July 10, 2018 2:10 PM
To: Chan, Aaron Chun Yew; richard.pur...@linuxfoundation.org; 
yocto@yoctoproject.org; Burton, Ross; Eggleton, Paul
Subject: Re: [yocto] [PATCH] [yocto-autobuilder] master.cfg: Defaults 
autobuilder URL based on FQDN

Hi Aron,

On 2018-07-10 05:18, Aaron Chan wrote:
This patch is to enable auto-assignments buildbot URL based on Hosts FQDN.
The socket module allows the retrieval on FQDN and constructs the entire
URL by default, this default settings can be overwritten in c['buildbotURL']
based on local administrator preferences.

Signed-off-by: Aaron Chan <aaron.chun.yew.c...@intel.com>
---
   master.cfg | 7 +++++--
   1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/master.cfg b/master.cfg
index fca80d2..49ddeb4 100644
--- a/master.cfg
+++ b/master.cfg
@@ -4,6 +4,7 @@
   import os
   import imp
   import pkg_resources
+import socket

   from buildbot.plugins import *
   from buildbot.plugins import db
@@ -55,6 +56,7 @@ imp.reload(services)
   imp.reload(www)

   c = BuildmasterConfig = {}
+url = os.path.join('http://', socket.getfqdn() + ':' + str(config.web_port) + 
'/')

Why use `os.path.join()` here? It isn't supposed to be used to construct
url's, and is overkill for this case, and you'd end up with "http:///...";.

// Martin


   # Disable usage reporting
   c['buildbotNetUsageData'] = None
@@ -76,6 +78,7 @@ c['www'] = www.www
   c['workers'] = workers.workers

   c['title'] = "Yocto Autobuilder"
-c['titleURL'] = "https://autobuilder.yoctoproject.org/main/";
+c['titleURL'] = url
   # visible location for internal web server
-c['buildbotURL'] = "https://autobuilder.yoctoproject.org/main/";
+# - Default c['buildbotURL'] = "https://autobuilder.yoctoproject.org/main/";
+c['buildbotURL'] = url


--
Kind regards,
Martin Hundebøll
Embedded Linux Consultant

+45 61 65 54 61
mar...@geanix.com

Geanix IVS
DK39600706


--
Kind regards,
Martin Hundebøll
Embedded Linux Consultant

+45 61 65 54 61
mar...@geanix.com

Geanix IVS
DK39600706
--
_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto

Reply via email to