Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
e44dd3b4
Commit
e44dd3b4
authored
14 years ago
by
Alexandre Savard
Browse files
Options
Downloads
Patches
Plain Diff
[#4116] Make account enabled by default ini migration script (IP2IP account)
parent
4381c0fe
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/ini2yaml.py
+54
-32
54 additions, 32 deletions
tools/ini2yaml.py
with
54 additions
and
32 deletions
tools/ini2yaml.py
+
54
−
32
View file @
e44dd3b4
...
...
@@ -2,16 +2,16 @@ import os
import
yaml
from
ConfigParser
import
ConfigParser
as
cp
#
path = os.environ['HOME'] + "/.config/sflphone/sflphonedrc"
path
=
"
sflphonedrc
"
path
=
os
.
environ
[
'
HOME
'
]
+
"
/.config/sflphone/sflphonedrc
"
#
path = "sflphonedrc"
c
=
cp
()
c
.
read
(
path
)
accnodes
=
[
'
srtp
'
,
'
tls
'
,
'
zrtp
'
]
auxnodes
=
[
'
alsa
'
,
'
pulse
'
,
'
dtmf
'
]
dico
=
{}
dico
[
'
Accounts
'
]
=
[]
dico
[
'
accounts
'
]
=
[]
# Dictionary used to convert string used in prior configuration file to new one.
conversion
=
{
# addressbook
...
...
@@ -69,6 +69,7 @@ conversion = {
'
zidfile
'
:
'
zidFile
'
,
# account
'
accounts
'
:
'
accounts
'
,
'
ip2ip
'
:
'
IP2IP
'
,
'
alias
'
:
'
alias
'
,
'
displayname
'
:
'
displayName
'
,
...
...
@@ -109,64 +110,85 @@ conversion = {
# to be removed
'
listenerport
'
:
'
port
'
,
}
# parcourt des sections du fichier d'origine
# Dictionary to convert sections string
section_conversion
=
{
'
Accounts
'
:
'
accounts
'
,
'
Addressbook
'
:
'
addressbook
'
,
'
Audio
'
:
'
audio
'
,
'
Hooks
'
:
'
hooks
'
,
'
Preferences
'
:
'
preferences
'
,
'
VoIPLink
'
:
'
voipPreferences
'
,
'
Shortcuts
'
:
'
shortcuts
'
}
# run over every sections in original file
for
sec
in
c
.
sections
():
#
les comptes sont maintenant dans
un
e
list
e de comptes
#
accounts are now stored in an acco
un
t
list
if
'
Account
'
in
sec
or
sec
==
'
IP2IP
'
:
dsec
=
'
A
ccounts
'
#
dict
tempora
ire pour insertion ulterieure des comptes dans le
diction
naire
daccount
=
{}
dsec
=
'
a
ccounts
'
# tempora
ry account dictionary to be inserted in main
diction
ary
daccount
=
{}
daccount
[
'
id
'
]
=
sec
#
dict
tempora
ire pour insertion ulterieure des nodes dans le compte
subdic
=
{}
# prepar
ation du dictionnaire pour les nodes du compte
# tempora
ry account dictionary to be inserted in account nodes
subdic
=
{}
# prepar
ing account dictionary
for
x
in
accnodes
:
subdic
[
x
]
=
{}
#
parcourt des
options
#
run over every
options
for
opt
in
c
.
options
(
sec
):
spl
=
opt
.
split
(
'
.
'
)
#
si nous avons affaire a
un node
#
if this is an acco
un
t
node
if
spl
[
0
]
in
accnodes
:
#
on ajoute dans le sous dict du compte
#
add into the account dictionary
print
spl
[
1
]
subdic
[
spl
[
0
]][
conversion
[
spl
[
1
]]]
=
c
.
get
(
sec
,
opt
)
#
sinon l'
option
est
attache
e au compte
#
else, the
option
s is
attache
d to the primary dictionary
else
:
daccount
[
spl
[
len
(
spl
)
-
1
]]
=
c
.
get
(
sec
,
opt
)
# insert
ion des nodes dans le compte
# insert
account nodes in account dictionary
for
x
in
accnodes
:
daccount
[
x
]
=
subdic
[
x
]
#insert
ion du compte dans le dictionnaire principal
#
insert
account dictionary in main dictionary
dico
[
dsec
].
append
(
daccount
)
else
:
dsec
=
sec
dsec
=
sec
tion_conversion
[
sec
]
dico
[
dsec
]
=
{}
#print dsec
#for opt in c.options(sec):
# dico[dsec][opt] = c.get(sec, opt)
# print opt
subdic
=
{}
# prepar
ation du
diction
n
a
ire pour les nodes de la section
# prepar
e
dictiona
ry for section's node
for
x
in
auxnodes
:
subdic
[
x
]
=
{}
#
parcourt des option
s
#
run over all field
s
for
opt
in
c
.
options
(
sec
):
spl
=
opt
.
split
(
'
.
'
)
#
si nous avons affaire a un
node
#
if this is a
node
if
spl
[
0
]
in
auxnodes
:
#
on ajoute dans le sous dict du compte
#
add into sections dictionary
print
spl
[
1
]
subdic
[
spl
[
0
]][
conversion
[
spl
[
1
]]]
=
c
.
get
(
sec
,
opt
)
#
sinon l'
option
est
attache
e au compte
#
else if this
option
is
attache
d to an accout
else
:
dico
[
sec
][
spl
[
len
(
spl
)
-
1
]]
=
c
.
get
(
sec
,
opt
)
# inserti
on des nodes dans le compte
dico
[
sec
tion_conversion
[
sec
]
][
spl
[
len
(
spl
)
-
1
]]
=
c
.
get
(
sec
,
opt
)
# inserti
ng the node into the account
for
x
in
auxnodes
:
if
subdic
[
x
]:
dico
[
sec
][
x
]
=
subdic
[
x
]
dico
[
section_conversion
[
sec
]][
x
]
=
subdic
[
x
]
# Make sure all accunt are enabled (especially IP2IP)
for
acc
in
dico
[
'
accounts
'
]:
acc
[
'
enable
'
]
=
'
true
'
# Save in new configuration file
newPath
=
os
.
environ
[
'
HOME
'
]
+
"
/.config/sflphone/sflphonedrc
"
# newPath = 'blah.yml'
f
=
open
(
'
blah.yml
'
,
'
wr
'
)
# Save new configuration file
f
=
open
(
newPath
,
'
wr
'
)
f
.
write
(
yaml
.
dump
(
dico
,
default_flow_style
=
False
))
f
.
close
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment