Can't access PlayerGui in ServerScript when a purchase is completed - roblox

So, I want to make if a Player succesfully donate in my game, an GUi will show up in the Player screen with a Tween Animation that says Purchase is completed
When I tested it out, I expected when I trying to test to purchase donate, it will show up a GUi, But, the actual results is already showed up in Output. When I tried to playtest it, An error ServerScriptService.Purchases:14: attempt to index nil with 'WaitForChild' showed up in Output
I already searched on Google and still can't understand.
Here's the code:
-- Products for purchases
local Donate1ProductID = 1296480045
local Donate2ProductID = 1296484976
local Donate3ProductID = 1296484935
local Donate4ProductID = 1296484932
local Donate5ProductID = 1296483595
local Donate6ProductID = 1296484931
local Donate7ProductID = 1296484933
-- Required depencies/services
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Main = LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("AntiPiracyCheck")
-- Code
MarketplaceService.ProcessReceipt = function(receiptInfo)
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if receiptInfo.ProductId == Donate1ProductID or Donate2ProductID or Donate3ProductID or Donate4ProductID or Donate5ProductID or Donate6ProductID or Donate7ProductID then
Main.PurchaseSuccess:TweenPosition(
UDim2.new(0.258, 0,0.279, 0),
Enum.EasingDirection.InOut,
Enum.EasingStyle.Quad,
1,
true
)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end

Because it's a server script LocalPlayer doesn't exist therefore it's a nil value.
-- Products for purchases
local Donate1ProductID = 1296480045
local Donate2ProductID = 1296484976
local Donate3ProductID = 1296484935
local Donate4ProductID = 1296484932
local Donate5ProductID = 1296483595
local Donate6ProductID = 1296484931
local Donate7ProductID = 1296484933
-- Required depencies/services
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
-- Code
game.Players.PlayerAdded:Connect(function(LocalPlayer)
MarketplaceService.ProcessReceipt = function(receiptInfo)
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
local Main = player:WaitForChild("PlayerGui"):WaitForChild("AntiPiracyCheck")
if receiptInfo.ProductId == Donate1ProductID or Donate2ProductID or Donate3ProductID or Donate4ProductID or Donate5ProductID or Donate6ProductID or Donate7ProductID then
Main.PurchaseSuccess:TweenPosition(
UDim2.new(0.258, 0,0.279, 0),
Enum.EasingDirection.InOut,
Enum.EasingStyle.Quad,
1,
true
)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end

Related

How to configure external postgresql database in chef automate server

I want to know how can we configure chef automate server to use external postgresql database. I have one chef server which is configured with external elasticsearch and postgresql database, now i want to use that same postgresql database in chef automate server. Can somebody tell me how can i achieve that?
Here is my delivery.rb file configuration
delivery_fqdn "192.168.0.101"
delivery['chef_username'] = "delivery"
delivery['chef_private_key'] = "/etc/delivery/delivery.pem"
delivery['chef_server'] = "https://192.168.0.102/organizations/automate_org"
insights['enable'] = true
elasticsearch['urls'] = ['http://192.168.0.103:9200']
elasticsearch['external'] = true
data_collector['token'] = 'helloworld123'
postgresql['version'] = '9.6'
postgresql['external'] = true
postgresql['vip'] = '192.168.0.103'
postgresql['port'] = '5432'
postgresql['username'] = 'admin'
postgresql['superuser_username'] = 'admin'
postgresql['superuser_password'] = 'admin123'
Here is my chef-server.rb
postgresql['external'] = true
postgresql['vip'] = '192.168.0.103'
postgresql['port'] = 5432
postgresql['db_superuser'] = 'admin'
postgresql['db_superuser_password'] = 'admin123'
opscode_erchef['search_provider'] = 'elasticsearch'
opscode_solr4['external'] = true
opscode_solr4['external_url'] = 'http://192.168.0.103:9200'
opscode_solr4['elasticsearch_shard_count'] = 3
opscode_solr4['elasticsearch_replica_count'] = 2
opscode_erchef['search_queue_mode'] = 'batch'
rabbitmq['enable'] = false
rabbitmq['management_enabled'] = false
rabbitmq['queue_length_monitor_enabled'] = false
opscode_expander['enable'] = false
dark_launch['actions'] = false
data_collector['root_url'] = 'https://192.168.0.101/data-collector/v0'
profiles['root_url'] = 'https://192.168.0.101'
Chef Automate server still uses Chef Server, see Automate setup here. delivery.rb is for Automate settings that are non-defaults. The Chef Server settings likely still need set in chef-server.rb, see here, then run chef-server-ctl reconfigure since Automate still stores cookbooks and data in Chef Server.

Zope/Plone code reload after deployment on production

Is there a way to reload the code without restarting Zope when in Production ?
New features are implemented almost once in 2 days and have to be uploaded to the server. The only way it works currently is by restarting the zeo server and all instances. Can't use "plone.reload" as it only works in the development environment when the debug mode is on. Below is the buildout.cfg content
[buildout]
parts =
# instance
zeo
client1
client2
client3
zopepy
zopeskel
test
# mysql
# varnish-build
# varnish
supervisor
pidproxy
extends =
https://dist.plone.org/versions/zope-2-13-19-versions.cfg
find-links =
https://dist.plone.org/release/4.2.4
https://dist.plone.org/thirdparty
extensions =
mr.developer
# buildout.dumppickedversions
sources = sources
versions = versions
develop =
[versions]
plone.recipe.zeoserver = 1.3.1
plone.recipe.zope2instance = 4.2.8
five.localsitemanager = 2.0.5
Products.PluginRegistry = 1.3
Products.CMFCore = 2.2.7
Products.GenericSetup = 1.7.3
Products.ZSQLMethods = 2.13.4
zope.interface = 3.6.7
zope.app.publication = 3.12.0
#setuptools = 17.1.1
funcsigs = 0.4
openpyxl = 2.4.0
plone.reload = 2.0.2
[zeo]
recipe = plone.recipe.zeoserver
zeo-address = 127.0.0.1:9100
zeo-var = ${buildout:directory}/var
blob-storage = ${zeo:zeo-var}/blobstorage
#ggs = plone.app.blob
[client1]
recipe = plone.recipe.zope2instance
http-address = 9081
zeo-client = on
zeo-address = ${zeo:zeo-address}
shared-blob = on
blob-storage = ${zeo:zeo-var}/blobstorage
user = admin:Slick_RP#21!
products = ${buildout:directory}/matrix_git/prod/
debug-mode = off
verbose-security = off
eggs =
# pillow
mysql-python
simplejson
haversine
openpyxl
requests
httpagentparser
ordereddict
python-memcached
# python-crontab
# setuptools
Products.CMFCore
Products.ZMySQLDA
# Products.SQLAlchemyDA
Products.PluggableAuthService
# Products.ZopeProfiler
# Products.MemoryProfiler
# reportlab
Products.BeakerSessionDataManager
collective.fsexternalmethod
plone.reload
zope-conf-additional =
extensions ${buildout:directory}/matrix_git/Extensions
<product-config beaker>
session.type file
session.data_dir ${buildout:directory}/var/sessions/data
session.lock_dir ${buildout:directory}/var/sessions/lock
session.key beaker.session
session.secret secret
</product-config>
zcml =
collective.fsexternalmethod
plone.reload
event-log-max-size = 5 MB
event-log-old-files = 5
access-log-max-size = 20 MB
access-log-old-files = 10
[client2]
recipe = plone.recipe.zope2instance
http-address = 9082
zeo-client = ${client1:zeo-client}
zeo-address = ${client1:zeo-address}
blob-storage = ${client1:blob-storage}
shared-blob = ${client1:shared-blob}
user = ${client1:user}
products = ${client1:products}
debug-mode = off
verbose-security = off
eggs = ${client1:eggs}
zcml = ${client1:zcml}
zope-conf-additional = ${client1:zope-conf-additional}
event-log-max-size = ${client1:event-log-max-size}
event-log-old-files = ${client1:event-log-old-files}
access-log-max-size = ${client1:access-log-max-size}
access-log-old-files = ${client1:access-log-old-files}
[client3]
recipe = plone.recipe.zope2instance
http-address = 9083
zeo-client = ${client1:zeo-client}
zeo-address = ${client1:zeo-address}
blob-storage = ${client1:blob-storage}
shared-blob = ${client1:shared-blob}
user = ${client1:user}
products = ${client1:products}
debug-mode = off
verbose-security = off
eggs = ${client1:eggs}
zcml = ${client1:zcml}
zope-conf-additional = ${client1:zope-conf-additional}
event-log-max-size = ${client1:event-log-max-size}
event-log-old-files = ${client1:event-log-old-files}
access-log-max-size = ${client1:access-log-max-size}
access-log-old-files = ${client1:access-log-old-files}
[zopepy]
recipe = zc.recipe.egg
eggs = ${client1:eggs}
interpreter = zopepy
scripts = zopepy
[test]
recipe = zc.recipe.testrunner
defaults = ['--auto-color', '--auto-progress']
eggs =
${client1:eggs}
[zopeskel]
recipe = zc.recipe.egg
eggs =
ZopeSkel
PasteScript
[mysql]
recipe = zest.recipe.mysql
# Note that these urls usually stop working after a while... thanks...
mysql-url = http://downloads.mysql.com/archives/mysql-5.0/mysql-5.0.86.tar.gz
mysql-python-url = http://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.3.tar.gz
[varnish-build]
recipe = zc.recipe.cmmi
url = ${varnish:download-url}
[varnish]
recipe = plone.recipe.varnish
daemon = ${buildout:parts-directory}/varnish-build/sbin/varnishd
bind = 127.0.0.1:8000
backends = 127.0.0.1:8080
cache-size = 50M
[pidproxy]
recipe = zc.recipe.egg
eggs = supervisor
scripts = pidproxy
[supervisor]
recipe = collective.recipe.supervisor
port = 127.0.0.1:24007
serverurl = http://127.0.0.1:24007
programs =
# 10 mysql ${buildout:directory}/bin/pidproxy [${buildout:directory}/var/mysql/mysql.pid ${buildout:directory}/parts/mysql/install/bin/mysqld_safe --pid-file=${buildout:directory}/var/mysql/mysql.pid --socket=${buildout:directory}/var/mysql.socket] ${buildout:directory} true
20 zeo ${buildout:directory}/bin/zeo [console] ${buildout:directory} true
30 client1 ${buildout:directory}/bin/client1 [console] ${buildout:directory} true
40 client2 ${buildout:directory}/bin/client2 [console] ${buildout:directory} true
50 client3 ${buildout:directory}/bin/client3 [console] ${buildout:directory} true
If you are deploying so frequently, you can either deploy at low traffic times (i.e. at night).
If the website should be always up, you could have two sets of Plone instances: one set is active and serving requests, the second one is not active.
When updating, the offline servers are updated and when they are done, a switch is turned (HAProxy for example) to replace the active servers.
You could even have all servers available always, but for updating, put some offline while they are updated.
As others, and you as well are pointing, I would never use plone.reload or similar development tools in production.
Yes there is a way, allthough I'd never do that in production it's a great time-saver when developing, to do a reload within a browser-view:
from plone.reload.code import reload_code
from Products.Five.browser import BrowserView
class View(BrowserView):
def __call__(self):
reload_code()
return 'Code loaded.'
Then call the view with the name you registered it with upon the site. This even works in non-debug-mode while the instance is running in background. Tested with a standalone instance (non-ZEO).

Why does this email's cc property not work properly in ASP classic?

When a task is assigned to someone, the person that the task was previously assigned to is supposed to also be notified. However, this is not working. I am not sure why this email isn't being sent out to the .Cc email. Does anyone know how to fix this code? (The email IS being send to the msg.to recipient, and "testcc" does return the valid email address value.
Set msg=Server.CreateObject("CDONTS.NewMail")
strSQL = "select emailaddress from UserList where userid = "&assign&";"
Set rs = objConnection.Execute(strSQL, ,adCmdText)
if not(rs.BOF and rs.EOF) then
temp = rs("emailaddress")
if(temp<>"" and temp<>"NULL") then
msg.To = rs("emailaddress")
end if
end if
strSQL = "select emailaddress from UserList where username = '"&assignedTo&"';"
Set rs = objConnection.Execute(strSQL, ,adCmdText)
if not(rs.BOF and rs.EOF) then
msg.Cc = rs("emailaddress")
testcc = rs("emailaddress")
end if
Response.write(testcc)
msg.From = "support#test.com"
msg.Subject = relname & " TaskID: "&maintid&" - New Task Assignment"
msg.MailFormat = CdoMailFormatMime
msg.BodyFormat = CdoBodyFormatHTML
Enotes = ""
msg.Body = Body & Enotes
msg.Send()
1st of all:
CDONTS was deprecated in Windows 2000 and removed completely in Windows 2003.
I suggest to use CDOSYS, which can be used from windows 2000 to windows 2008.
Code sample:
On Error Resume Next
Set myMail = Server.CreateObject("CDO.Message")
myMail.BodyPart.charset = "unicode-1-1-utf-8"
myMail.Subject = EmailSubject
myMail.HTMLBody = EmailBody
myMail.From = EmailFrom
myMail.To = EmailTO
myMail.Cc = EmailCC
myMail.BCc = EmailBCC
myMail.Send
Result = 2
If Err.Number <> 0 Then
Result = -1
End If
Set myMail = Nothing

Lua Copas: Sender coroutine just stops working

I have a problem using latest Copas in Lua 5.2.
I wrote a simple script (see below) which creates two server sockets: "RX" and "TX".
"RX" listens for messages from connected clients, "TX" transmits those messages to clients connected to "TX".
The problem is: In the beginning, after server start-up, everything works fine. But after a certain amount of messages, the "TX" server loop is not executed anymore, no more messages are transmitted.
There is no error message, nothing. It just stops working.
Am I using Copas wrong? What is the problem?
This is the (simplified) code:
local copas = require("copas")
local socket = require("socket")
local pl_class = require("pl.class")
-- Connection between a server and a client
pl_class.ClientConnection()
function ClientConnection:_init(connectionName, socketToClient)
self.connectionName = connectionName
self.socketToClient = socketToClient
self.queueMessagesToSend = {}
end
function ClientConnection:popMessageToSend()
return table.remove(self.queueMessagesToSend, 1);
end
function ClientConnection:pushMessageToSend(theMessage)
table.insert(self.queueMessagesToSend, theMessage)
end
-- Server base class
pl_class.Server()
function Server:_init(serverName, serverPort)
self.serverName = serverName
self.serverPort = serverPort
self.connectedClients = {}
end
function Server:initServing()
local server = socket.bind("*", self.serverPort)
print("[" .. self.serverName .. "] Waiting for client connections on port " .. self.serverPort .. "...")
copas.addserver(server, function(c) return self.connectionHandler(copas.wrap(c), c:getpeername()) end )
end
-- Class for send-only servers
pl_class.ServerSendOnly(Server)
function ServerSendOnly:_init(serverName, serverPort)
self:super(serverName, serverPort)
self.connectionHandler = function (socketToClient, clientHost, clientPort)
local connObject = ClientConnection(clientHost..":"..tostring(clientPort), socketToClient)
self.connectedClients[connObject.connectionName] = connObject
while true do
local currMessage = connObject:popMessageToSend()
if currMessage then
copas.send(connObject.socketToClient, currMessage)
end
copas.sleep(0.01)
end
self.connectedClients[connObject.connectionName] = nil
end
end
function ServerSendOnly:broadcastMessage(currMessage)
for connName,connObject in pairs(self.connectedClients) do
connObject:pushMessageToSend(currMessage .. "\r\n")
end
end
-- Class for receive-only servers
pl_class.ServerReceiveOnly(Server)
function ServerReceiveOnly:_init(serverName, serverPort)
self:super(serverName, serverPort)
self.queueMessagesReceived = {}
self.connectionHandler = function (socketToClient, clientHost, clientPort)
local connObject = ClientConnection(clientHost..":"..tostring(clientPort), socketToClient)
self.connectedClients[connObject.connectionName] = connObject
while true do
local currDataReceived = copas.receive(connObject.socketToClient)
if currDataReceived ~= nil then
local currInfo = {client=connObject.connectionName, data=currDataReceived}
table.insert(self.queueMessagesReceived, currInfo)
end
end
self.connectedClients[connObject.connectionName] = nil
end
end
function ServerReceiveOnly:popMessageReceived()
return table.remove(self.queueMessagesReceived, 1);
end
-- Setup servers
local serverSend = ServerSendOnly("ServerTX", 2345)
local serverReceive = ServerReceiveOnly("ServerRX", 1234)
serverSend:initServing()
serverReceive:initServing()
-- Main loop: Pass messages which arrived at the RX server to the clients
-- connected to the TX servers ("RX" and "TX" are used from the server's POV)
while true do
copas.step()
local currMessage = serverReceive:popMessageReceived()
if currMessage then
print("[" .. serverReceive.serverName .. "] MESSAGE RECEIVED FROM '" .. currMessage.client .."': " .. currMessage.data)
serverSend:broadcastMessage(currMessage.data)
end
end

How to send outlook mails without opening outlook in PC by testcomplete

i am trying to send outlook mail using vb script language in testcomplete. i am able to send but if the outlook is opened in my PC then only mail will be sent and if the oulook is not opened in my pc,my mail will not be sent untill opening the outllok even after executing this script
here is my code:
Function SendMail
Dim objOutLook, NamespaceMAPI,objNewMail, fso, SendReceiveControls
Dim strTo,strCc ,strBcc ,strSubject, AccountName,strAttachmentPath
strSubject="test"
strTo=yyy#yy.com
strCc=XXX#XX.com
strBcc =zzz#zzz.com
strAttachmentPath="c:\text.txt"
If strTo ="" and strCc = "" and strBcc =""Then
Exit function
ElseIf strSubject =""Then
Exit function
End If
Set objOutLook = CreateObject("Outlook.Application")
Set NamespaceMAPI = objOutLook.GetNamespace("MAPI")
Set objNewMail = objOutLook.CreateItem(olMailItem)
objOutLook.DisplayAlerts =True
objNewMail.TO = strTo
objNewMail.CC = strCc
objNewMail.BCC=strBcc
objNewMail.Subject = strSubject
objNewMail.Body = strMsg
If strAttachmentPath <> "" Then
Set fso =CreateObject("Scripting.FileSystemObject")
If fso.FileExists(strAttachmentPath) Then
objNewMail.Attachments.Add(strAttachmentPath)
objNewMail.display
Else
msgbox "Attachment File Does not exists"
End If
End If
AccountName="XXXXXX#XXXX.com"
' Finding the "Send/Receive" control
Set SendReceiveControls = NamespaceMAPI.GetDefaultFolder("Inbox")._
CommandBars("STANDARD").Controls("Send/Receive")
Set Item = Nothing
'msgbox "send:"&SendReceiveControls.Controls.Count
For I = 1 To SendReceiveControls.Controls.Count
If InStr(SendReceiveControls.Controls(I).Caption, AccountName) > 0 Then
Set Item = SendReceiveControls.Controls(I)
'msgbox "send1"&SendReceiveControls.Controls(I)
Exit For
End If
Next
' Executing the "Send/Receive" action
Item.Controls(1).Execute()
objOutLook.Quit
''''''' Releasing objects '''''''
Set objOutLook =Nothing
Set objNewMail = Nothing
Set fso = Nothing
End Function
please suggest me how to handle this...thanks in advance
Do you really need to send it with outlook?
I use this javascript code to send the email, then, in outlook, you just need to mark it as not spam, otherwise, it goes directly to the spam inbox
function SendEmail(mFrom, mTo, mSubject, mBody, username, password)
{
var i, schema, mConfig, mMessage;
try
{
schema = "http://schemas.microsoft.com/cdo/configuration/";
mConfig = Sys.OleObject("CDO.Configuration");
mConfig.Fields.Item(schema + "sendusing") = 2; // cdoSendUsingExchange
mConfig.Fields.Item(schema + "smtpserver") = "STMP SERVER ADDRESS HERE"; // SMTP server
mConfig.Fields.Item(schema + "smtpserverport") = 25; // Port number
mConfig.Fields.Item(schema + "smtpauthenticate") = 1; // Authentication mechanism
mConfig.Fields.Item(schema + "sendusername") = username; // User name (if needed)
mConfig.Fields.Item(schema + "sendpassword") = password; // User password (if needed)
mConfig.Fields.Update();
mMessage = Sys.OleObject("CDO.Message");
mMessage.Configuration = mConfig;
mMessage.From = mFrom;
mMessage.To = mTo;
mMessage.Subject = mSubject;
mMessage.HTMLBody = mBody;
mMessage.Send();
}
catch (exception)
{
Log.Error("E-mail cannot be sent", exception.description);
return false;
}
Log.Message("Message to <" + mTo + "> was successfully sent");
return true;
}
Try objNewMail.Body.Send instead of trying to execute the send and receive button. Here's a simple example:
Function SendMail()
Dim objOutlook, objNewMail
Set objOutLook = CreateObject("Outlook.Application")
Set objNewMail = objOutLook.CreateItem(olMailItem)
objNewMail.TO = "myrecip#test.com"
objNewMail.Subject = "test"
objNewMail.Body = "test"
objNewMail.Send
End Function