-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogramasExternos.html
More file actions
executable file
·224 lines (201 loc) · 16.8 KB
/
Copy pathprogramasExternos.html
File metadata and controls
executable file
·224 lines (201 loc) · 16.8 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>HashLDash</title>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="../style.css" />
<link rel="stylesheet" href="../pythonStyle.css" />
</head>
<body>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="banner">
<div class="bannerImg">
<center>
<img src="../images/title.png">
</center>
</div>
</div>
<div class="numbers">
0 1 0 0 0 0 1 0 0 1 1 0 0 1 0 1 0 1 1 0 1 1 0 1 0 0 1 0 0 0 0 0 0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 1 1 0 0 1 0 1 0 1 1 0 1 1 1 0 0 1 1 1 0 0 1 1 0 1 1 0 0 0 0 1 0 1 1 1 0 0 1 1 0 1 0 0 0 0 0 0 0 1 1 0 0 1 1 1 0 1 1 0 1 1 0 1 0 1 1 0 0 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0 0 1 0 1 1 1 0 0 1 1 0 0 0 1 1 0 1 1 0 1 1 1 1 0 1 1 0 1 1 0 1 0 0 1 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 1 0 1 1 0 1 1 1 1 0 1 1 0 1 1 1 0 0 1 1 1 0 1 0 0 0 1 1 0 0 1 0 1 0 0 1 0 1 1 0 1 0 1 1 0 1 1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 1 1 0 0 1 0 1 0 1 1 1 0 0 1 1 0 1 1 1 0 1 0 0 0 1 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 0 1 0 1 1 0 1 0 0 1 0 1 1 1 0 1 0 0 0 1 1 0 1 1 1 1 0 0 1 0 0 0 0 1
</div>
<div class="menu">
<a class="menuItem" href="../index.html">Notícias</a>
<a class="menuItem" href="../cursos.html">Cursos</a>
<a class="menuItem" href="../contato.html">Contato</a>
<a class="menuItem" href="../doacao.html">Doação</a>
</div>
<center>
<div id="app">
<a class="googlePlay" href='https://play.google.com/store/apps/details?id=com.crearyx.hashforum&pcampaignid=pcampaignidMKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1'>
<img class="googlePlay" src="../images/hashForum.png">
<img class="googlePlay" alt='Disponível no Google Play' src='https://play.google.com/intl/pt-BR/badges/static/images/badges/pt_badge_web_generic.png'/>
</a>
</div>
<div class="thepage">
<div class="propLateralEsquerda">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- propLateral -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-7220446760691137"
data-ad-slot="6308862097"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- propLateral -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-7220446760691137"
data-ad-slot="6308862097"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- propLateral -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-7220446760691137"
data-ad-slot="6308862097"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
<div class="main">
<h1> Chatbot - Como abrir programas e arquivos externos </h1>
<p> Neste vídeo ensino como executar programas do sistema operacional e abrir arquivos de extensões diversas com os devidos programas pelo Python. Para isso utilizamos o módulo 'sys' para identificar o sistema operacional, 'os' para executar programas e abrir arquivos no windows e o 'subprocess' no sistema GNU/Linux. </p>
<div class="aulaImg">
<a href="https://www.youtube.com/watch?v=aeUXnUd0mDA&list=PLsMpSZTgkF5C_Kkc0XBtM3OVLBsjUkjzy&index=18">
<img src="../images/programasexternos.jpg">
<p class="legend">Clique na imagem para assistir a aula no YouTube.</p>
</a>
</div>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- propLateral -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-7220446760691137"
data-ad-slot="6308862097"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>
</p><p>Infelizmente, não existe nenhum comando no Python que consegue executar programas ou arquivos que funciona em todos os sistemas operacionais. Então, dependendo do sistema operacional, vamos ter que escrever o código diferentemente. Mas, felizmente, isso não é complicado!
</p><p>
</p><h2>Identificando o Sistema Operacional
</h2><p>
</p><p>Primeiramente vamos identificar em qual sistema o nosso script está rodando. Para isso vamos importar o módulo sys:
</p><p>
</p><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
</pre></div>
<p>
</p><p>Agora podemos identificar o sistema da seguinte maneira:
</p><p>
</p><div class="highlight"><pre><span></span><span class="n">sys</span><span class="o">.</span><span class="n">platform</span>
</pre></div>
<p>
</p><p>Isso nos dará o nome da plataforma em que estamos rodando. No meu caso, esse comando devolve 'linux'. Mas se você estiver no Windows, ele mostrará 'win32' ou 'cygwin' No Mac irá aparecer 'darwin' e assim por diante.
</p><p>
</p><p>Após identificar qual o sistema que estamos, vamos aprender a abrir programas e arquivos em cada plataforma.
</p><p>
</p><h3>Windows
</h3><p>
</p><p>Para executar programas ou abrir arquivos no Windows, vamos utilizar o módulo 'os':
</p><p>
</p><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span>
</pre></div>
<p>
</p><p>Para abrir um programa, precisamos chamar a função 'startfile' com o caminho completo do programa que desejarmos abrir. Se o programa estiver no PATH (caminho padrão), é só digitar o nome do programa.
</p><p>
</p><div class="highlight"><pre><span></span><span class="n">os</span><span class="o">.</span><span class="n">startfile</span><span class="p">(</span><span class="s1">'notepad.exe'</span><span class="p">)</span> <span class="c1"># Se estiver no caminho</span>
<span class="n">os</span><span class="o">.</span><span class="n">startfile</span><span class="p">(</span><span class="s1">'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'</span><span class="p">)</span> <span class="c1"># Se não estiver no caminho</span>
</pre></div>
<p>
</p><p>Para sites, precisamos colocar o endereço completo:
</p><p>
</p><div class="highlight"><pre><span></span><span class="n">os</span><span class="o">.</span><span class="n">startfile</span><span class="p">(</span><span class="s2">"https://hashldash.github.io"</span><span class="p">)</span>
</pre></div>
<p>
</p><h3>Linux
</h3><p>
</p><p>No linux vamos utilizar o módulo subprocess:
</p><p>
</p><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">subprocess</span> <span class="kn">as</span> <span class="nn">s</span>
</pre></div>
<p>
</p><p>A parte 'as s' no código acima é para simplificarmos o nome do módulo. Ou seja, ao invés de escrever 'subprocess' quando formos chamar o comando do módulo, vamos apenas escrever 's'.
</p><p>
</p><p>Para executar um programa, podemos utilizar o comando shell que abre o programa. Por exemplo:
</p><p>
</p><div class="highlight"><pre><span></span><span class="n">s</span><span class="o">.</span><span class="n">Popen</span><span class="p">(</span><span class="s1">'chromium'</span><span class="p">)</span>
</pre></div>
<p>
</p><p>Irá abrir o navegador chromium, e assim por diante. Para abrir arquivos, podemos utilizar o comando 'xdg-open' do Linux para escolher um programa adequado para abrir o arquivo. Por exemplo:
</p><p>
</p><div class="highlight"><pre><span></span><span class="n">s</span><span class="o">.</span><span class="n">Popen</span><span class="p">([</span><span class="s1">'xdg-open'</span><span class="p">,</span><span class="s1">'https://hashldash.github.io'</span><span class="p">])</span> <span class="c1"># para site</span>
<span class="n">s</span><span class="o">.</span><span class="n">Popen</span><span class="p">([</span><span class="s1">'xdg-open'</span><span class="p">,</span><span class="s1">'planilha.xls'</span><span class="p">])</span> <span class="c1"># para arquivos</span>
</pre></div>
<p>
</p><p>No vídeo eu dou um exemplo de como utilizar estes comandos, implementando a abertura e execução de programas no chatbot.
</p><p>
</p><a href="https://github.com/HashLDash/Site/tree/master/resources/PythonNaPratica/18-openFile"><p class="download">Faça o download dos arquivos desta aula aqui.</p>
<div class="fb-comments" data-href="https://hashldash.github.io/Site/" data-numposts="5"></div>
</div>
<div class="propLateralDireita">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- propLateral -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-7220446760691137"
data-ad-slot="6308862097"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- propLateral -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-7220446760691137"
data-ad-slot="6308862097"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- propLateral -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-7220446760691137"
data-ad-slot="6308862097"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>
</center>
</body>
</html>