-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoPiStartup.py
34 lines (28 loc) · 957 Bytes
/
autoPiStartup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import ConfigParser
def UserSaved(path):
config = ConfigParser.ConfigParser()
config.read(path+'/autopi.config')
#check that LoginInfo section exists, create and
#retrun false if no LoginInfo section
if ('LoginInfo' in config.sections()) != True:
config.add_section('LoginInfo')
config_file = open(path+'/autopi.config','w')
config.write(config_file)
config_file.close()
return False
if (config.has_option('LoginInfo', 'username') or config.has_option('LoginInfo','password')) != True:
return False
return True
def createConfig(path):
open(path+'/autopi.config','w').close()
def SaveUser(path,username,password):
print('In autoPiStartup.SaveUser')
config = ConfigParser.ConfigParser()
config.read(path+'/autopi.config')
config_file = open(path+'/autopi.config','w')
config.set('LoginInfo','Username',username)
config.set('LoginInfo','Password',password)
config.write(config_file)
config_file.close()
return True