-
Notifications
You must be signed in to change notification settings - Fork 6
/
pip_new_session.ado
106 lines (78 loc) · 2.34 KB
/
pip_new_session.ado
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*==================================================
project: Execute in each new Stata session
Author: R.Andres Castaneda
E-email: [email protected]
url:
Dependencies: The World bank
----------------------------------------------------
Creation Date: 30 Nov 2021 - 16:05:24
Modification Date:
Do-file version: 01
References:
Output:
==================================================*/
/*==================================================
0: Program set up
==================================================*/
program define pip_new_session, rclass
version 16.1
syntax [anything(name=subcommand)] ///
[, ///
path(string) ///
pause ///
]
if ("`pause'" == "pause") pause on
else pause off
*##s
* ---- Initial time parameters
if ("${pip_old_session}" != "") exit
if ("${pip_lastupdate}" != "") {
local day_diff = date("${pip_date_file}","YMD") - ///
date("${pip_lastupdate}","YMD")
if (`day_diff' <= 31) {
noi disp "Check for updates will be done in `=31-`day_diff'' days"
global pip_old_session "1"
exit
}
}
*##e
/*==================================================
1: Update PIP
==================================================*/
pip_update, path(`path')
local pip_source = "`r(src)'"
local bye = "`r(bye)'"
/*==================================================
2: Dependencies
==================================================*/
*---------- check SSC commands
/*
local ssc_cmds missings
noi disp in y "Note: " in w "{cmd:pip} requires the packages " ///
"below from SSC: " _n in g "`ssc_cmds'"
foreach cmd of local ssc_cmds {
capture which `cmd'
if (_rc != 0) {
ssc install `cmd'
noi disp in g "{cmd:`cmd'} " in w _col(15) "installed"
}
}
adoupdate `ssc_cmds', ssconly
if ("`r(pkglist)'" != "") adoupdate `r(pkglist)', update ssconly
*/
* ----- Globals
local tgl = `"global pip_source = "`pip_source'""'
pip_setup replace, pattern("pip_lastupdate") /*
*/ new(`"global pip_lastupdate "${pip_date_file}""')
pip_setup replace, pattern("pip_source") new(`"`tgl'"')
pip_setup run
`bye'
end
exit
/* End of do-file */
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
Notes:
1.
2.
3.
Version Control: